Spaces:
Runtime error
Runtime error
| from flask import Flask, render_template, request, jsonify | |
| from utils import model_predict | |
| app = Flask(__name__) | |
| def home(): | |
| return render_template("index.html") | |
| def predict(): | |
| email = request.form.get('content') | |
| prediction = model_predict(email) | |
| return render_template("index.html", prediction=prediction, email=email) | |
| # Create an API endpoint | |
| def predict_api(): | |
| data = request.get_json(force=True) # Get data posted as a json | |
| email = data['content'] | |
| prediction = model_predict(email) | |
| return jsonify({'prediction': prediction, 'email': email}) # Return prediction | |
| if __name__ == "__main__": | |
| app.run(host="0.0.0.0", port=8080, debug=True) | |