Skip to content

Instantly share code, notes, and snippets.

@sonesuke
Created October 28, 2017 12:05
Show Gist options
  • Save sonesuke/6e4c05f7f06da094e20f3f0f758037be to your computer and use it in GitHub Desktop.
Save sonesuke/6e4c05f7f06da094e20f3f0f758037be to your computer and use it in GitHub Desktop.
falcon upload
import falcon
from falcon_multipart.middleware import MultipartMiddleware
# http --from localhost:8888 file@sample.txt
class SampleResource:
def on_post(self, req, resp, **kwargs):
f = req.get_param('file')
raw = f.file.read()
with open('file.txt', 'wb') as f:
f.write(raw)
api = falcon.API(middleware=[MultipartMiddleware()])
api.add_route('/sample', SampleResource())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment