Project

General

Profile

Standalone » History » Version 1

Version 1/6 - Next » - Current version
Jan Klopper, 2012-03-13 15:13


Standalone

µWeb's standalone mode allows you to develop an application or website without installing / configuring a full-fledged webserver like apache. By keeping all of the environment the same as it would be inside a normal webserver it allows you to code once, and run on both types of install.

A default standalone server can be started by issuing a 'start' command on the router. Obviously 'stop' and 'restart' are also supported.

The default ip/port the standalone will bind to are: localhost:8082, which you can then use to connect to your server via a browser.

Custom ip/port

Using a custom port and or ip can be attained by setting a config file in the router with the 'CONFIG' variable, and in that config list the following settings:

[standalone]
port = 4001

If you want to use 1 config file for multiple standalone servers, eg, you want to centralize certain settings, but have others on a server by server basis, you can issue a more specific block for each server using the package name as defined in the router using the 'PACKAGE' variable. For example, a demo router would look like this:

import uweb
import pages
CONFIG = '../demo.conf'
PACKAGE = 'demo'
PAGE_CLASS = pages.PageMaker
ROUTES = (
    ('/', 'requestIndex'),
    ('(/.*)', 'requestFail'))

uweb.ServerSetup()


This would read from the ../demo.conf file (relative to the location of the router) and look for both a [standalone] and a [standalone:demo] subsection
[standalone:demo]
port = 8080

[standalone]
access_logging = 0
error_logging = 0

As you can see, by setting the access_logging and error_logging vars you can make sure the server doesn't log these actions and thus speeds up a bit.