Spaces:
Runtime error
Runtime error
Commit ·
f8a8a2f
1
Parent(s): 0a20852
Update app.py
Browse files2 unmodified lines3456678109101114121314151617211819203 unmodified lines24252631272833293035313233341 unmodified line3637384339402 unmodified linesimport osimport jsonfrom dotenv import load_dotenv
load_dotenv()app = flask.Flask(__name__, template_folder="./")app.config["DEBUG"] = True
@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(): try:3 unmodified lines for key, value in incoming.items(): if isinstance(value, int): if value > 0: result[key] = str(value - 1) result[key] = value - 1 else: result[key] = "0" result[key] = 0 else: result[key] = "0" # Если значение не является целым числом, присваиваем "0" result[key] = 0 # Если значение не является целым числом, присваиваем 0 response = jsonify(result) return response except Exception as e:1 unmodified line "error": str(e) } return jsonify(error_response), 500
if __name__ == '__main__': app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))app.py+3-8