Skip to content

Instantly share code, notes, and snippets.

@bgweber
Created May 1, 2019 04:39
Show Gist options
  • Save bgweber/b3c9a83eaaa8d3686ce47976788102ad to your computer and use it in GitHub Desktop.
Save bgweber/b3c9a83eaaa8d3686ce47976788102ad to your computer and use it in GitHub Desktop.
# 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