main Module

This file is part of the web2py Web Framework
Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>

The gluon wsgi application

gluon.main.wsgibase(environ, responder)[source]

The gluon wsgi application. The first function called when a page is requested (static or dynamic). It can be called by paste.httpserver or by apache mod_wsgi (or any WSGI-compatible server).

  • fills request with info
  • the environment variables, replacing ‘.’ with ‘_’
  • adds web2py path and version info
  • compensates for fcgi missing path_info and query_string
  • validates the path in url

The url path must be either:

  1. for static pages:
  • /<application>/static/<file>
  1. for dynamic pages:
  • /<application>[/<controller>[/<function>[/<sub>]]][.<extension>]

The naming conventions are:

  • application, controller, function and extension may only contain [a-zA-Z0-9_]
  • file and sub may also contain ‘-‘, ‘=’, ‘.’ and ‘/’
gluon.main.save_password(password, port)[source]

Used by main() to save the password in the parameters_port.py file.

gluon.main.appfactory(wsgiapp=<function wsgibase>, logfilename='httpserver.log', profiler_dir=None, profilerfilename=None)[source]

generates a wsgi application that does logging and profiling and calls wsgibase

Parameters:
  • wsgiapp – the base application
  • logfilename – where to store apache-compatible requests log
  • profiler_dir – where to store profile files
class gluon.main.HttpServer(ip='127.0.0.1', port=8000, password='', pid_filename='httpserver.pid', log_filename='httpserver.log', profiler_dir=None, ssl_certificate=None, ssl_private_key=None, ssl_ca_certificate=None, min_threads=None, max_threads=None, server_name=None, request_queue_size=5, timeout=10, socket_timeout=1, shutdown_timeout=None, path=None, interfaces=None)[source]

Bases: object

the web2py web server (Rocket)

start()[source]

start the web server

stop(stoplogging=False)[source]

stop cron and the web server