Nov-06-2019, 01:49 PM
How can I get input data from a form via post without using any framework ?
Getting form data ?
|
Nov-06-2019, 01:49 PM
How can I get input data from a form via post without using any framework ?
Nov-06-2019, 04:03 PM
using the example below I get the output :
ws_body = int(environ['CONTENT_LENGTH']) ws_input = environ['wsgi.input'].read(ws_body) ws_print = ws_input status = '200 OK' headers = [('Content-type', 'text/html; charset=utf-8')] ws_output(status, headers) return [str(ws_print).encode('utf-8')] output-> b'' ?
As i mention before look at how other has done this.
As these task task can be hard to figure out at low WSGI level using the specification Doc in PEP 333 or PEP 3333 Werkzeug is a thin layer above WSGI,and stuff Flask is build on. Form Data Parsing werkzeug Quote:When does Werkzeug Parse? In there example you see raw data that comes in from a form. data = '--foo\r\nContent-Disposition: form-data; name="test"\r\n'\ '\r\nHello World!\r\n--foo--'If i make own parser as a quick test,not looking how they have made the parser. >>> import re >>> >>> r = re.search(r"name=\"\w+\"(.*?)--", data, re.DOTALL) >>> r.group(1).strip() 'Hello World!'Regex is common tool to use when parsing other Parsing In Python: Tools And Libraries. PyParsing -- A Python Parsing Module.
Nov-07-2019, 02:13 PM
(Nov-07-2019, 02:03 PM)snippsat Wrote: As i mention before look at at how other has done this. As these task task can be hard to figure out at low WSGI level using the specification Doc in PEP 333 or PEP 3333 Form Data Parsing werkzeugQuote:When does Werkzeug Parse? Werkzeug parses the incoming data under the following situations:In there example you see raw data that comes in from a form. Too bad this is a puzzle it would be interesting for python language itself to provide a native function within wsgiref to handle this somewhat similar issue as the request_uri () function for accessing url data. Could you think of something like request_form () or request_input () to gain access to data sent by forms? |
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Post HTML Form Data to API Endpoints | Dexty | 0 | 1,867 |
Nov-11-2021, 10:51 PM Last Post: Dexty |
|
POST request with form data issue web scraping | hoff1022 | 1 | 3,589 |
Aug-14-2020, 10:25 AM Last Post: kashcode |
|
Get form data | JohnnyCoffee | 0 | 2,499 |
Jan-29-2020, 01:39 PM Last Post: JohnnyCoffee |
|
How to send data from remotely hosted HTML form to Pi | sajid | 2 | 3,460 |
Jun-27-2019, 10:28 PM Last Post: sajid |
|
Django - Retrieve form data | justantest | 0 | 3,400 |
May-23-2019, 11:47 AM Last Post: justantest |