Created
May 25, 2018 13:26
-
-
Save rhythmize/eea29e0be69bd7f0592b9c3e9e753538 to your computer and use it in GitHub Desktop.
Sample test for Flasgger to send data in formBody of GET 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 | |
from flasgger import Swagger | |
app = Flask(__name__) | |
Swagger(app) | |
@app.route('/') | |
def main_route(): | |
""" | |
Test Endpoint | |
--- | |
tags: | |
- Test | |
parameters: | |
- name: data | |
in: formData | |
required: True | |
type: string | |
description: data to send | |
responses: | |
200: | |
description: data received successfully | |
404: | |
description: data not found in request form | |
""" | |
if 'data' not in request.form.keys(): | |
return 'data not found in request form', 404 | |
return 'data received: ' + str(request.form['data']) | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment