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-0.2.3.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

cgiw-0.2.3-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cgiw-0.2.3.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for cgiw-0.2.3.tar.gz
Algorithm Hash digest
SHA256 62f784e3255edea37d60d8e3fcab955107b2f159f57cbebfb2cb147892b5f549
MD5 9199f37f088bbcb673f4b5e12ccdd53b
BLAKE2b-256 d162e7b0165d474061020258336f7e6d6147992f4bda14807b707e6712a2f23e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cgiw-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for cgiw-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3b90e747e1b7a2e43b712205dc69238fb143cb57835af78a3e5950b8ac1a4363
MD5 d06964ae0399a5b566a2e2360ec521ec
BLAKE2b-256 06dc220097f237cd0d2ecd3c43850036627049fca63b7c0a7a3dc055d045db93

See more details on using hashes here.

Supported by

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