-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
30 lines (23 loc) · 974 Bytes
/
app.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
from flask import Flask
from flask import request
from util import get_prediction
from flask.json import jsonify
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
@app.route("/predict", methods=["POST"])
def predict():
if request.method == "POST":
tweet = request.json["tweet"]
result = get_prediction(tweet)
return jsonify({"tweet": tweet, "status": result})
if __name__ == "__main__":
# This is used when running locally only. When deploying to Google App
# Engine, a webserver process such as Gunicorn will serve the app. This
# can be configured by adding an `entrypoint` to app.yaml.
# Flask's development server will automatically serve static files in
# the "static" directory. See:
# http://flask.pocoo.org/docs/1.0/quickstart/#static-files. Once deployed,
# App Engine itself will serve those files as configured in app.yaml.
app.run(host="127.0.0.1", port=8080, debug=True)