Spaces:
Runtime error
Runtime error
Commit ·
e91a221
1
Parent(s): 89cab91
Update app.py
Browse files2 unmodified lines345678910111213141516171819202122232419202122232425262728252627282930313233343536373839404130422 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: incoming = request.get_json() print(incoming) result = {} for key, value in incoming.items(): if int(value) > 0: result[key] = str(int(value) - 1) else: result[key] = "0" response = jsonify(result) return response incoming = request.get_json() print(incoming) result = {} for key, value in incoming.items(): if int(value) > 0: result[key] = str(int(value) - 1) else: result[key] = "0" response = jsonify(result) return response except Exception as e: error_response = { "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.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))app.py+23-11