CGI Programming in Python

Python has excellent support for CGI scripts.


Using the built-in cgi module, you can read query parameters and POST bodies, and process file uploads. This is enough for small scripts or single-purpose pages. If you want to build a whole web application, you should look into a web framework like

import cgi

print('Content-Type: text/plain\n')
form = cgi.FieldStorage()

name = form.getvalue('name') or 'World'
print(f'Hello, {name}!')

Bottle is a microframework that’s used outside CGI as well. It allows you to create your applications in higher-level logic.

Comments BETA

Page built on Fri 14 Jun 2019 12:36:16 AM BST