cgiw-0.1.4
توضیحات
A framework for building python cgi scripts
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | cgiw-0.1.4 |
| نام | cgiw |
| نسخه کتابخانه | 0.1.4 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | James Rao <jamesnarayanrao@gmail.com> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/cgiw/ |
| مجوز | - |
# CGI Wrapper
This is a lightweight, extensible framework for writing CGI scripts in python.
## Install
```
pip install cgiw
```
## Use
This package takes care of parsing the query, headers and body (if post). It parses some basic mime types such as ```application/json``` and ```application/x-www-form-urlencoded```, and allows the developer to use custom parsers. All handlers must return a tuple containing three items: the status string, a dictionary of headers, and the body. There are some basic response functions implemented to avoid having to construct this tuple from scratch.
### Example
Here is an example that demonstrates the functionality of the framework.
```python
#!/bin/python3
from cgiw import run
from cgiw.responses import redirect
from cgiw.decorators import wrap_headers, wrap_body
def process_headers(headers):
# do stuff
return headers
def process_body(body):
# do stuff
return body
@wrap_headers(process_headers)
@wrap_body(process_body)
def handler(query, headers, body):
# do stuff
return redirect('/test', {'query': 'string'})
run(post=handler)
```
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl cgiw-0.1.4:
pip install cgiw-0.1.4.whl
نصب پکیج tar.gz cgiw-0.1.4:
pip install cgiw-0.1.4.tar.gz