Created
June 14, 2019 10:35
-
-
Save hkaraoguz/06b4c99d8711e11808e54e55da9d2eb9 to your computer and use it in GitHub Desktop.
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
"""main.py | |
An example script for demoing swaggerui functionality with quart | |
""" | |
import os | |
from quart import Quart, request, flash, make_response | |
from quart_swagger_blueprint import swagger_ui | |
app = Quart(__name__) | |
@app.route('/hello_world', methods=['POST']) | |
async def hello_world(): | |
if request.method == 'POST': | |
data = await request.get_json() | |
# print(data) | |
if data: | |
if data.get('name'): | |
text = "Hello World "+data["name"] | |
response = await make_response(text, 200) | |
return response | |
response = await make_response("Bad Request", 400) | |
return response | |
# register the swaggerui display | |
app.register_blueprint(swagger_ui) | |
app.run(host="0.0.0.0", port=5000, debug=True, use_reloader=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment