Multipart form handling should be performant, straightforward, and leave full control of the parsing process to the user, i.e. no surprising magic such as automatic creation of large files and saving anything there by default (although tools/helpers may exist to assist in that too).
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 io | |
import falcon | |
import requests | |
class Proxy(object): | |
"""Try, for instance ``/examples/forms1.html``.""" | |
UPSTREAM = 'https://www.simplehtmlguide.com' |
Official documentation: Multipart Forms
Install Falcon (3.0+ required for ASGI) and the
uvicorn
ASGI app server:pip install -U "falcon >= 3.0.0" pip install uvicorn
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
# # docker run --rm -it -p 27017:27017 mongo | |
# $ gunicorn --workers 8 --worker-class=meinheld.gmeinheld.MeinheldWorker test:app | |
import itertools | |
import random | |
import falcon | |
import pymongo | |
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
# Credit: @vytas7 (Vytautas Liuolia) | |
import queue | |
import signal | |
import threading | |
import time | |
import uuid | |
import falcon |
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 | |
import falcon.routing | |
class FloatConverter(falcon.routing.BaseConverter): | |
def convert(self, value): | |
try: | |
return float(value) | |
except ValueError: | |
return None |
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 random | |
import time | |
import uuid | |
import falcon | |
class RequestMonitor: | |
def __init__(self, req, resp): |
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.asgi | |
import httpx | |
class Proxy(object): | |
UPSTREAM = 'https://falconframework.org' | |
def __init__(self): | |
self._client = httpx.AsyncClient() |
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
#!/usr/bin/env python | |
import asyncio | |
import logging | |
import threading | |
import uuid | |
import falcon | |
import falcon.asgi | |
import gunicorn.app.base | |
import uvicorn |
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 cgi | |
import functools | |
import falcon | |
class TextHandler(falcon.media.BaseHandler): | |
DEFAULT_CHARSET = 'utf-8' | |
@classmethod |
OlderNewer