Last active
April 29, 2020 22:26
-
-
Save ivanpanshin/6d3229ed0daf7fa1f482cac205aa83dd to your computer and use it in GitHub Desktop.
app.py with POST request
This file contains hidden or 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
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