Module Expr Str Assign NameStore Str If UnaryOpNot Call AttributeLoad NameLoad attr body TryExcept body Assign NameStore Call NameLoad Str Str TryFinally body Assign NameStore Call AttributeLoad NameLoad attr finalbody Expr Call AttributeLoad NameLoad attr handlers ExceptHandler body Assign NameStore Str FunctionDef arguments args NameParam defaults body Assign NameStore ListLoad TupleLoad Str Str TupleLoad Str Str TupleLoad Str Str For TupleStore NameStore NameStore ListComp Call AttributeLoad Call AttributeLoad NameLoad attr attr comprehension NameStore Call AttributeLoad NameLoad attr Str BoolOpAnd Call AttributeLoad NameLoad attr UnaryOpNot Call AttributeLoad Call AttributeLoad NameLoad attr attr Str body If UnaryOpNot Call AttributeLoad NameLoad attr Str body Assign NameStore BinOpAdd Str NameLoad If Call AttributeLoad NameLoad attr Str body Assign NameStore SubscriptLoad NameLoad Slice Num Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr Str Index Num AugAssignAdd NameStore ListLoad TupleLoad BinOpMod Str NameLoad BinOpMod Str NameLoad TupleLoad BinOpMod Str NameLoad BinOpMod Str NameLoad TupleLoad BinOpMod Str NameLoad BinOpMod Str NameLoad TupleLoad BinOpMod Str NameLoad BinOpMod Str NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore ListLoad For TupleStore NameStore NameStore ListComp Call AttributeLoad Call AttributeLoad NameLoad attr attr comprehension NameStore Call AttributeLoad NameLoad attr Str BoolOpAnd Call AttributeLoad NameLoad attr UnaryOpNot Call AttributeLoad Call AttributeLoad NameLoad attr attr Str body If UnaryOpNot Call AttributeLoad NameLoad attr Str body Assign NameStore BinOpAdd Str NameLoad If Call AttributeLoad NameLoad attr Str body Assign NameStore SubscriptLoad NameLoad Slice Num Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr Str Index Num AugAssignAdd NameStore ListLoad TupleLoad BinOpMod Str NameLoad Str TupleLoad BinOpMod Str NameLoad Str TupleLoad BinOpMod Str NameLoad Str Return NameLoad decorator_list Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad FunctionDef arguments args defaults body Expr Str Pass decorator_list If CompareEq NameLoad Str body TryExcept body Import alias handlers ExceptHandler type NameLoad body Import alias Import alias Expr Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Import alias ImportFrom alias alias alias alias Expr Call NameLoad Expr Call NameLoad keyword NameLoad Import alias Expr Call AttributeLoad NameLoad attr
N/A N/A 
autoroutes writes routes for you based on a simpler routing
configuration file called routes.conf. Example:

----- BEGIN routes.conf-------
127.0.0.1   /examples/default
domain1.com /app1/default
domain2.com /app2/default
domain3.com /app3/default
----- END ----------

It maps a domain (the left-hand side) to an app (one app per domain),
and shortens the URLs for the app by removing the listed path prefix. That means:

http://domain1.com/index is mapped to /app1/default/index
http://domain2.com/index is mapped to /app2/default/index

It preserves admin, appadmin, static files, favicon.ico and robots.txt:

http://domain1.com/favicon.ico  /welcome/static/favicon.ico
http://domain1.com/robots.txt   /welcome/static/robots.txt
http://domain1.com/admin/...    /admin/...
http://domain1.com/appadmin/... /app1/appadmin/...
http://domain1.com/static/...   /app1/static/...

and vice-versa.

To use, cp scripts/autoroutes.py routes.py

and either edit the config string below, or set config = "" and edit routes.conf
 N/A config 
127.0.0.1   /examples/default
domain1.com /app1/default
domain2.com /app2/default
domain3.com /app3/defcon3
 N/A N/A N/A N/A config strip N/A N/A N/A N/A config_file N/A open routes.conf r N/A N/A N/A config N/A N/A config_file read N/A N/A N/A N/A config_file close N/A N/A N/A N/A config auto_in N/A N/A apps N/A N/A N/A routes N/A N/A /robots.txt /welcome/static/robots.txt N/A /favicon.ico /welcome/static/favicon.ico N/A /admin$anything /admin$anything N/A N/A domain path N/A N/A N/A N/A N/A x strip split N/A x N/A N/A apps split N/A N/A N/A x strip N/A N/A N/A N/A N/A x strip startswith # N/A N/A N/A N/A N/A path startswith / N/A N/A path N/A / path N/A N/A N/A path endswith / N/A N/A path N/A path N/A -1 N/A app N/A N/A N/A path split / N/A 1 N/A routes N/A N/A N/A .*:https?://(.*\.)?%s:$method / domain N/A %s path N/A N/A .*:https?://(.*\.)?%s:$method /static/$anything domain N/A /%s/static/$anything app N/A N/A .*:https?://(.*\.)?%s:$method /appadmin/$anything domain N/A /%s/appadmin/$anything app N/A N/A .*:https?://(.*\.)?%s:$method /$anything domain N/A %s/$anything path N/A routes N/A auto_out N/A N/A apps N/A N/A N/A routes N/A N/A N/A domain path N/A N/A N/A N/A N/A x strip split N/A x N/A N/A apps split N/A N/A N/A x strip N/A N/A N/A N/A N/A x strip startswith # N/A N/A N/A N/A N/A path startswith / N/A N/A path N/A / path N/A N/A N/A path endswith / N/A N/A path N/A path N/A -1 N/A app N/A N/A N/A path split / N/A 1 N/A routes N/A N/A N/A /%s/static/$anything app /static/$anything N/A N/A /%s/appadmin/$anything app /appadmin/$anything N/A N/A %s/$anything path /$anything N/A routes N/A N/A routes_in N/A auto_in config N/A routes_out N/A auto_out config __routes_doctest N/A N/A N/A N/A N/A 
    Dummy function for doctesting autoroutes.py.

    Use filter_url() to test incoming or outgoing routes;
    filter_err() for error redirection.

    filter_url() accepts overrides for method and remote host:
        filter_url(url, method='get', remote='0.0.0.0', out=False)

    filter_err() accepts overrides for application and ticket:
        filter_err(status, application='app', ticket='tkt')

    >>> filter_url('http://domain1.com/favicon.ico')
    'http://domain1.com/welcome/static/favicon.ico'
    >>> filter_url('https://domain2.com/robots.txt')
    'https://domain2.com/welcome/static/robots.txt'
    >>> filter_url('http://domain3.com/fcn')
    'http://domain3.com/app3/defcon3/fcn'
    >>> filter_url('http://127.0.0.1/fcn')
    'http://127.0.0.1/examples/default/fcn'
    >>> filter_url('HTTP://DOMAIN.COM/app/ctr/fcn')
    'http://domain.com/app/ctr/fcn'
    >>> filter_url('http://domain.com/app/ctr/fcn?query')
    'http://domain.com/app/ctr/fcn?query'
    >>> filter_url('http://otherdomain.com/fcn')
    'http://otherdomain.com/fcn'
    >>> regex_filter_out('/app/ctr/fcn')
    '/app/ctr/fcn'
    >>> regex_filter_out('/app1/ctr/fcn')
    '/app1/ctr/fcn'
    >>> filter_url('https://otherdomain.com/app1/default/fcn', out=True)
    '/fcn'
    >>> filter_url('http://otherdomain.com/app2/ctr/fcn', out=True)
    '/app2/ctr/fcn'
    >>> filter_url('http://domain1.com/app1/default/fcn?query', out=True)
    '/fcn?query'
    >>> filter_url('http://domain2.com/app3/defcon3/fcn#anchor', out=True)
    '/fcn#anchor'
     N/A N/A N/A N/A __name__ __main__ N/A N/A N/A N/A gluon.main N/A N/A N/A ImportError N/A N/A sys N/A os N/A N/A N/A os chdir N/A N/A N/A os path dirname N/A N/A N/A os path dirname __file__ N/A N/A N/A N/A sys path append N/A N/A N/A os path dirname N/A N/A N/A os path dirname __file__ N/A gluon.main gluon.rewrite regex_select load filter_url regex_filter_out N/A N/A regex_select N/A N/A load routes __file__ N/A doctest N/A N/A N/A doctest testmod