import os from flask import Flask from flask import jsonify from flask import render_template from flask import request from modules.model import inference app = Flask(__name__) # app_dir = os.path.dirname(os.path.abspath(__file__)) @app.route("/", defaults={"js": "demo"}) def index(js): return render_template(f"{js}.html", js=js) @app.route("/predict", methods=["POST"]) def predict(): sample = os.getenv('SAMPLE_TEXT') text = request.form.get('text', sample, type=str) text = sample if text == "" else text return jsonify(result=inference(text)) if __name__ == "__main__": app.run(debug = False)