Difference between revisions of "Short Notes on Flask and Flask-RestPlus"
From PaskvilWiki
(Created page with "== Structuring the Project == == Handling Requests == == File Upload == <pre>@ns.route('/') class Handle(Resource): @ns.param('data', description='We will just return t...") |
(No difference)
|
Revision as of 13:02, 9 February 2017
Structuring the Project
Handling Requests
File Upload
@ns.route('/') class Handle(Resource): @ns.param('data', description='We will just return this.', _in='formData', type='string', required=True) @ns.param('file', description='We will save this as /tmp/test.jpg.', _in='formData', type='file', required=True) def post(self): with open('/tmp/test.jpg', 'wb') as f: f.write(request.files['file'].read()) return {'data': request.form['data']}