|
import flask |
|
from flask import request, jsonify |
|
import os |
|
from 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("/test") |
|
def zapro(): |
|
return flask.render_template('zapro.html') |
|
|
|
|
|
@app.route("/api", methods=['GET']) |
|
def api(): |
|
|
|
ph = request.args.get('ph') |
|
|
|
|
|
ec = request.args.get('ec') |
|
|
|
|
|
response = { |
|
"ph_out": ph, |
|
"ec_out": ec |
|
} |
|
|
|
|
|
return jsonify(response) |
|
|
|
@app.route("/avp", methods=["POST"]) |
|
def avp(): |
|
incoming = request.get_json() |
|
|
|
|
|
|
|
datas = incoming["bazis"] |
|
|
|
|
|
if isinstance(datas, str): |
|
|
|
datas = eval(datas) |
|
|
|
|
|
for key in datas: |
|
value = datas[key] |
|
|
|
|
|
if value > 0: |
|
datas[key] = value - 1 |
|
|
|
|
|
response = {"bazis_out": datas} |
|
|
|
return jsonify(response) |
|
|
|
|
|
if __name__ == '__main__': |
|
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860))) |