Spaces:
Sleeping
Sleeping
File size: 645 Bytes
cb1f9b3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
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 = True)
|