Skip to main content

A framework for building python cgi scripts

Project description

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.

#!/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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cgiw-1.0.5.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cgiw-1.0.5-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file cgiw-1.0.5.tar.gz.

File metadata

  • Download URL: cgiw-1.0.5.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for cgiw-1.0.5.tar.gz
Algorithm Hash digest
SHA256 3266218fc7e3fe026455bb5f410997b1bc31b43210eb5c3bcda52b5ee82ecdc5
MD5 1802240222834d76ad38ba4bb76e5376
BLAKE2b-256 722a2c54927ef62b6735f11f99f3139fbb523e87a37ee67b9ae624ec485049ff

See more details on using hashes here.

File details

Details for the file cgiw-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: cgiw-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for cgiw-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8850e9d9dc0daf8a773c0721997ee83301e201f4d1e4b43e28d4c9f69954ebb2
MD5 ae63feaa9e10522534b8f5058ad8d26f
BLAKE2b-256 769208c548ce512d26e2ab3b9d786f479ecfc04d7604a73b6f42b970e175ec15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page