-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathecho.py
More file actions
26 lines (20 loc) · 678 Bytes
/
echo.py
File metadata and controls
26 lines (20 loc) · 678 Bytes
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
# load Flask
import flask
app = flask.Flask(__name__)
# define a predict function as an endpoint
@app.route("/", methods=["GET","POST"])
def predict():
data = {"success": False}
# check for passed in parameters
params = flask.request.json
if params is None:
params = flask.request.args
# if parameters are found, echo the msg parameter
if "msg" in params.keys():
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
if __name__ == '__main__':
app.run(host='0.0.0.0')