DmitrMakeev's picture
Update app.py
dc7fbe5
raw
history blame
971 Bytes
import flask
from flask import request, jsonify
import os
import json
from dotenv import load_dotenv
import re
load_dotenv()
app = flask.Flask(__name__, template_folder="./")
@app.route('/')
def index():
return flask.render_template('index.html')
@app.route("/", methods=["POST"])
def predict():
incoming = request.get_json()
print(incoming)
# Ваша логика обработки текста здесь
return "Your response here"
@app.route("/avp", methods=["POST"])
def avp():
incoming = request.get_data()
incoming = incoming.decode("utf-8")
incoming = re.sub(r"\\", "", incoming)
print(incoming)
# Сохраняем принятую JSON-строку в переменной "outs"
outs = json.loads(incoming)
# Возвращаем полученный объект JSON в ответе
return jsonify(outs)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))