-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmy_first_flask.py
30 lines (24 loc) · 996 Bytes
/
my_first_flask.py
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
28
29
30
from flask import Flask, request, jsonify, render_template
# create the flask app
app = Flask(__name__)
# what html should be loaded as the home page when the app loads?
@app.route('/')
def home():
return render_template('app_frontend.html', prediction_text="")
# define the logic for reading the inputs from the WEB PAGE,
# running the model, and displaying the prediction
@app.route('/predict', methods=['GET','POST'])
def predict():
# get the description submitted on the web page
a_description = request.form.get('description')
return render_template('app_frontend.html', prediction_text=a_description)
#return 'Description entered: {}'.format(a_description)
#@app.route('/prediction', methods=['GET', 'POST'])
#def prediction():
# if request.method == 'POST':
# prediction_data = request.json
# print(prediction_data)
# return jsonify({'result': prediction_data})
# boilerplate flask app code
if __name__ == "__main__":
app.run(debug=True)