 Falcon v2.0.0 Documentationalthough we do plan to add this feature in a future version. In the meantime, you can use the standard cgi.FieldStorage class to parse the request: # TODO: Either validate that content type is multipart/form-data here, or in another hook before allowing execution to proceed. # This must be done to avoid a bug in cgi.FieldStorage env = req.env env.setdefault('QUERY_STRING', '') # TODO: Add error handling, when the directly to the destination rather than # buffering using TemporaryFile (see http://goo.gl/Yo8h3P) form = cgi.FieldStorage(fp=req.stream, environ=env) (continues on next page) 5.1. User Guide 49 Falcon Documentation0 码力 | 184 页 | 671.87 KB | 1 年前3 Falcon v2.0.0 Documentationalthough we do plan to add this feature in a future version. In the meantime, you can use the standard cgi.FieldStorage class to parse the request: # TODO: Either validate that content type is multipart/form-data here, or in another hook before allowing execution to proceed. # This must be done to avoid a bug in cgi.FieldStorage env = req.env env.setdefault('QUERY_STRING', '') # TODO: Add error handling, when the directly to the destination rather than # buffering using TemporaryFile (see http://goo.gl/Yo8h3P) form = cgi.FieldStorage(fp=req.stream, environ=env) (continues on next page) 5.1. User Guide 49 Falcon Documentation0 码力 | 184 页 | 671.87 KB | 1 年前3
 Falcon v2.0.0 Documentationalthough we do plan to add this feature in a future version. In the meantime, you can use the standard cgi.FieldStorage class to parse the request: # TODO: Either validate that content type is multipart/form-data here, or in another hook before allowing execution to proceed. # This must be done to avoid a bug in cgi.FieldStorage env = req.env env.setdefault('QUERY_STRING', '') # TODO: Add error handling, when the directly to the destination rather than # buffering using TemporaryFile (see http://goo.gl/Yo8h3P) form = cgi.FieldStorage(fp=req.stream, environ=env) file_item = form[name] if file_item.file: # TODO: It's0 码力 | 265 页 | 299.57 KB | 1 年前3 Falcon v2.0.0 Documentationalthough we do plan to add this feature in a future version. In the meantime, you can use the standard cgi.FieldStorage class to parse the request: # TODO: Either validate that content type is multipart/form-data here, or in another hook before allowing execution to proceed. # This must be done to avoid a bug in cgi.FieldStorage env = req.env env.setdefault('QUERY_STRING', '') # TODO: Add error handling, when the directly to the destination rather than # buffering using TemporaryFile (see http://goo.gl/Yo8h3P) form = cgi.FieldStorage(fp=req.stream, environ=env) file_item = form[name] if file_item.file: # TODO: It's0 码力 | 265 页 | 299.57 KB | 1 年前3
 Falcon v3.1.1-b3 Documentationimplemented with a custom media handler: 5.1. User Guide 75 Falcon Documentation, Release 3.1.1b3 import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL = 8 stream.read() return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: try: indent = int(indent) req.path is based on the PATH_INFO CGI variable, which is already presented percent-decoded. Some application servers expose the raw URL under another, non-standard, CGI variable name. Let us implement a0 码力 | 378 页 | 1.29 MB | 1 年前3 Falcon v3.1.1-b3 Documentationimplemented with a custom media handler: 5.1. User Guide 75 Falcon Documentation, Release 3.1.1b3 import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL = 8 stream.read() return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: try: indent = int(indent) req.path is based on the PATH_INFO CGI variable, which is already presented percent-decoded. Some application servers expose the raw URL under another, non-standard, CGI variable name. Let us implement a0 码力 | 378 页 | 1.29 MB | 1 年前3
 Falcon v3.1.1-b1 Documentationimplemented with a custom media handler: 5.1. User Guide 75 Falcon Documentation, Release 3.1.1b1 import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL = 8 stream.read() return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: try: indent = int(indent) req.path is based on the PATH_INFO CGI variable, which is already presented percent-decoded. Some application servers expose the raw URL under another, non-standard, CGI variable name. Let us implement a0 码力 | 378 页 | 1.29 MB | 1 年前3 Falcon v3.1.1-b1 Documentationimplemented with a custom media handler: 5.1. User Guide 75 Falcon Documentation, Release 3.1.1b1 import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL = 8 stream.read() return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: try: indent = int(indent) req.path is based on the PATH_INFO CGI variable, which is already presented percent-decoded. Some application servers expose the raw URL under another, non-standard, CGI variable name. Let us implement a0 码力 | 378 页 | 1.29 MB | 1 年前3
 Falcon v3.1.1-a Documentationimplemented with a custom media handler: 5.1. User Guide 75 Falcon Documentation, Release 3.1.1 import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL = 8 stream.read() return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: try: indent = int(indent) req.path is based on the PATH_INFO CGI variable, which is already presented percent-decoded. Some application servers expose the raw URL under another, non-standard, CGI variable name. Let us implement a0 码力 | 378 页 | 1.29 MB | 1 年前3 Falcon v3.1.1-a Documentationimplemented with a custom media handler: 5.1. User Guide 75 Falcon Documentation, Release 3.1.1 import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL = 8 stream.read() return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: try: indent = int(indent) req.path is based on the PATH_INFO CGI variable, which is already presented percent-decoded. Some application servers expose the raw URL under another, non-standard, CGI variable name. Let us implement a0 码力 | 378 页 | 1.29 MB | 1 年前3
 Falcon v3.1.0 Documentationimplemented with a custom media handler: 5.1. User Guide 75 Falcon Documentation, Release 3.1.0 import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL = 8 stream.read() return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: try: indent = int(indent) req.path is based on the PATH_INFO CGI variable, which is already presented percent-decoded. Some application servers expose the raw URL under another, non-standard, CGI variable name. Let us implement a0 码力 | 362 页 | 1.29 MB | 1 年前3 Falcon v3.1.0 Documentationimplemented with a custom media handler: 5.1. User Guide 75 Falcon Documentation, Release 3.1.0 import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL = 8 stream.read() return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: try: indent = int(indent) req.path is based on the PATH_INFO CGI variable, which is already presented percent-decoded. Some application servers expose the raw URL under another, non-standard, CGI variable name. Let us implement a0 码力 | 362 页 | 1.29 MB | 1 年前3
 Falcon v3.1.1 Documentationimplemented with a custom media handler: 5.1. User Guide 75 Falcon Documentation, Release 3.1.1 import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL = 8 stream.read() return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: try: indent = int(indent) req.path is based on the PATH_INFO CGI variable, which is already presented percent-decoded. Some application servers expose the raw URL under another, non-standard, CGI variable name. Let us implement a0 码力 | 378 页 | 1.29 MB | 1 年前3 Falcon v3.1.1 Documentationimplemented with a custom media handler: 5.1. User Guide 75 Falcon Documentation, Release 3.1.1 import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL = 8 stream.read() return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: try: indent = int(indent) req.path is based on the PATH_INFO CGI variable, which is already presented percent-decoded. Some application servers expose the raw URL under another, non-standard, CGI variable name. Let us implement a0 码力 | 378 页 | 1.29 MB | 1 年前3
 Falcon v3.1.1-rc1 Documentationimplemented with a custom media handler: 5.1. User Guide 75 Falcon Documentation, Release 3.1.1rc1 import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL = 8 stream.read() return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: try: indent = int(indent) req.path is based on the PATH_INFO CGI variable, which is already presented percent-decoded. Some application servers expose the raw URL under another, non-standard, CGI variable name. Let us implement a0 码力 | 378 页 | 1.29 MB | 1 年前3 Falcon v3.1.1-rc1 Documentationimplemented with a custom media handler: 5.1. User Guide 75 Falcon Documentation, Release 3.1.1rc1 import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL = 8 stream.read() return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: try: indent = int(indent) req.path is based on the PATH_INFO CGI variable, which is already presented percent-decoded. Some application servers expose the raw URL under another, non-standard, CGI variable name. Let us implement a0 码力 | 378 页 | 1.29 MB | 1 年前3
 Falcon v3.0.0-b1 DocumentationJSON indent support to a Falcon app, this can be implemented with a custom media handler: import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: overriding the host and remote IP address in the WSGI environment, as well as setting arbitrary additional CGI variables in the WSGI environment. The simulate_request() method now supports passing a query string0 码力 | 1028 页 | 725.86 KB | 1 年前3 Falcon v3.0.0-b1 DocumentationJSON indent support to a Falcon app, this can be implemented with a custom media handler: import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: overriding the host and remote IP address in the WSGI environment, as well as setting arbitrary additional CGI variables in the WSGI environment. The simulate_request() method now supports passing a query string0 码力 | 1028 页 | 725.86 KB | 1 年前3
 Falcon v3.0.0 DocumentationJSON indent support to a Falcon app, this can be implemented with a custom media handler: import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: overriding the host and remote IP address in the WSGI environment, as well as setting arbitrary additional CGI variables in the WSGI environment. The simulate_request() method now supports passing a query string0 码力 | 1055 页 | 739.30 KB | 1 年前3 Falcon v3.0.0 DocumentationJSON indent support to a Falcon app, this can be implemented with a custom media handler: import cgi import json import falcon class CustomJSONHandler(falcon.media.BaseHandler): MAX_INDENT_LEVEL return json.loads(data.decode()) def serialize(self, media, content_type): _, params = cgi.parse_header(content_type) indent = params.get('indent') if indent is not None: overriding the host and remote IP address in the WSGI environment, as well as setting arbitrary additional CGI variables in the WSGI environment. The simulate_request() method now supports passing a query string0 码力 | 1055 页 | 739.30 KB | 1 年前3
共 34 条
- 1
- 2
- 3
- 4














