|
import flask |
|
from flask import request, jsonify |
|
import os |
|
from dotenv import load_dotenv |
|
|
|
load_dotenv() |
|
|
|
app = flask.Flask(__name__, template_folder="./") |
|
|
|
|
|
@app.route('/') |
|
def index(): |
|
return flask.render_template('index.html') |
|
|
|
|
|
@app.route("/avp", methods=["POST"]) |
|
def avp(): |
|
incoming = request.get_json() |
|
print(incoming) |
|
|
|
|
|
datas = incoming["bazis"] |
|
|
|
|
|
bazis_out = {} |
|
|
|
|
|
for key, value in datas.items(): |
|
|
|
if isinstance(value, (int, float)) and value > 0: |
|
bazis_out[key] = value - 1 |
|
else: |
|
bazis_out[key] = value |
|
|
|
|
|
return jsonify({"bazis_out": bazis_out}) |
|
|
|
|
|
if __name__ == '__main__': |
|
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860))) |