Created
May 1, 2019 04:39
-
-
Save bgweber/b3c9a83eaaa8d3686ce47976788102ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load Flask | |
import flask | |
app = flask.Flask(__name__) | |
# define a predict function as an endpoint | |
@app.route("/predict", methods=["GET","POST"]) | |
def predict(): | |
data = {"success": False} | |
# get the request parameters | |
params = flask.request.json | |
if (params == None): | |
params = flask.request.args | |
# if parameters are found, echo the msg parameter | |
if (params != None): | |
data["response"] = params.get("msg") | |
data["success"] = True | |
# return a response in json format | |
return flask.jsonify(data) | |
# start the flask app, allow remote connections | |
app.run(host='0.0.0.0') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment