1 # -*- coding: utf-8 -*-
3 Sphinx - Python documentation webserver
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 :copyright: 2007 by Armin Ronacher.
7 :license: Python license.
14 from sphinx
.web
.application
import setup_app
15 from sphinx
.web
.serve
import run_simple
18 from werkzeug
.debug
import DebuggedApplication
20 DebuggedApplication
= lambda x
, y
: x
24 opts
, args
= getopt
.getopt(argv
[1:], "dhf:")
26 if len(args
) != 1 or '-h' in opts
:
27 print 'usage: %s [-d] [-f cfg.py] <doc_root>' % argv
[0]
28 print ' -d: debug mode, use werkzeug debugger if installed'
29 print ' -f: use "cfg.py" file instead of doc_root/webconf.py'
32 conffile
= opts
.get('-f', os
.path
.join(args
[0], 'webconf.py'))
34 execfile(conffile
, config
)
36 port
= config
.get('listen_port', 3000)
37 hostname
= config
.get('listen_addr', 'localhost')
38 debug
= ('-d' in opts
) or (hostname
== 'localhost')
40 config
['data_root_path'] = args
[0]
41 config
['debug'] = debug
44 app
= setup_app(config
, check_superuser
=True)
46 app
= DebuggedApplication(app
, True)
49 if os
.environ
.get('RUN_MAIN') != 'true':
50 print '* Sphinx %s- Python documentation web application' % \
51 sphinx
.__version
__.replace('$', '').replace('Revision:', 'rev.')
53 print '* Running in debug mode'
55 run_simple(hostname
, port
, make_app
, use_reloader
=debug
)
58 if __name__
== '__main__':
59 sys
.exit(main(sys
.argv
))