Created
October 28, 2017 12:05
-
-
Save sonesuke/6e4c05f7f06da094e20f3f0f758037be to your computer and use it in GitHub Desktop.
falcon upload
This file contains 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
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