|
import flask |
|
from flask import request, jsonify |
|
import os |
|
import json |
|
import logging |
|
import pandas as pd |
|
from dotenv import load_dotenv |
|
load_dotenv() |
|
logging.basicConfig(level=logging.DEBUG, filename='debug.log', filemode='w') |
|
|
|
app = flask.Flask(__name__, template_folder="./") |
|
|
|
@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(): |
|
incoming = request.get_json() |
|
print(incoming) |
|
logging.debug(f"Incoming data: {incoming}") |
|
|
|
data = pd.DataFrame.from_dict(incoming, orient='index', columns=['value']) |
|
data['value'] -= 1 |
|
logging.debug(f"Incoming data: {incoming}") |
|
data.loc[data['value'] < 0, 'value'] = 0 |
|
response = data.to_dict()['value'] |
|
|
|
return jsonify(response) |
|
|
|
if __name__ == '__main__': |
|
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860))) |