psy4 / app.py
DmitrMakeev's picture
Update app.py
28e026b verified
raw
history blame
1.76 kB
import flask
from flask import request, jsonify
import os
from dotenv import load_dotenv
import globs
from flask import render_template
from api_logic import api
load_dotenv()
app = flask.Flask(__name__, template_folder="./")
app.config['DEBUG'] = True
@app.route("/")
def index():
return flask.render_template('index.html')
@app.route('/online', methods=['GET'])
def online():
return render_template('online.html')
@app.route('/online_api', methods=['GET'])
def online_api():
return jsonify(dey=globs.dey,
wek=globs.wek,
ph=globs.ph,
ec=globs.ec,
tS=globs.tS,
tA=globs.tA,
hDm=globs.hDm,
sVen=globs.sVen,
rFul=globs.rFul,
rLi=globs.rLi,
rWat=globs.rWat,
rRas=globs.rRas,
rPH=globs.rPH,
rEC=globs.rEC,
rSl=globs.rSl,
rLe=globs.rLe,
alW=globs.alW
)
@app.route('/settings', methods=['GET'])
def settings():
return render_template('settings.html')
@app.route('/settings_api', methods=['GET'])
def settings_api():
return jsonify(ph_eep=globs.ph_eep,
ph_on_eep=globs.ph_on_eep,
ec_eep=globs.ec_eep,
ec_A_eep=globs.ec_A_eep,
ec_B_eep=globs.ec_B_eep,
ec_C_eep=globs.ec_C_eep,
)
@app.route("/api", methods=['GET'])
def handle_api():
response = api()
return response
if __name__ == '__main__':
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))