Skip to content

Instantly share code, notes, and snippets.

@ivanpanshin
Last active April 29, 2020 22:26
Show Gist options
  • Save ivanpanshin/6d3229ed0daf7fa1f482cac205aa83dd to your computer and use it in GitHub Desktop.
Save ivanpanshin/6d3229ed0daf7fa1f482cac205aa83dd to your computer and use it in GitHub Desktop.
app.py with POST request
from flask import Flask, request, jsonify
server = Flask(__name__)
def run_request():
index = int(request.json['index'])
list = ['red', 'green', 'blue', 'yellow', 'black']
return list[index]
@server.route('/', methods=['GET', 'POST'])
def hello_world():
if request.method == 'GET':
return 'The model is up and running. Send a POST request'
else:
return run_request()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment