comparison hgweb.cgi @ 3868:6033d9f28052

hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts: - "import os" was missing in hgwebdir.cgi, added to comments for both script. - HGENCODING has to be set before importing hgweb, otherwise you'll get mixed encoding in changelog vs. file content/diffs. - "import sys" is only needed when changing sys.path - document purpose of cgitb.
author Thomas Arendsen Hein <thomas@intevation.de>
date Mon, 11 Dec 2006 14:30:50 +0100
parents 713e35dcc321
children 55860a45bbf2
comparison
equal deleted inserted replaced
3867:d210a1b05cf6 3868:6033d9f28052
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # An example CGI script to use hgweb, edit as necessary 3 # An example CGI script to use hgweb, edit as necessary
4 4
5 import cgitb, os, sys 5 # send python tracebacks to the browser if an error occurs:
6 import cgitb
6 cgitb.enable() 7 cgitb.enable()
7 8
8 # sys.path.insert(0, "/path/to/python/lib") # if not a system-wide install 9 # adjust python path if not a system-wide install:
9 from mercurial.hgweb.hgweb_mod import hgweb 10 #import sys
10 from mercurial.hgweb.request import wsgiapplication 11 #sys.path.insert(0, "/path/to/python/lib")
11 import mercurial.hgweb.wsgicgi as wsgicgi
12 12
13 # If you'd like to serve pages with UTF-8 instead of your default 13 # If you'd like to serve pages with UTF-8 instead of your default
14 # locale charset, you can do so by uncommenting the following lines. 14 # locale charset, you can do so by uncommenting the following lines.
15 # Note that this will cause your .hgrc files to be interpreted in 15 # Note that this will cause your .hgrc files to be interpreted in
16 # UTF-8 and all your repo files to be displayed using UTF-8. 16 # UTF-8 and all your repo files to be displayed using UTF-8.
17 # 17 #
18 # os.environ["HGENCODING"] = "UTF-8" 18 #import os
19 #os.environ["HGENCODING"] = "UTF-8"
20
21 from mercurial.hgweb.hgweb_mod import hgweb
22 from mercurial.hgweb.request import wsgiapplication
23 import mercurial.hgweb.wsgicgi as wsgicgi
19 24
20 def make_web_app(): 25 def make_web_app():
21 return hgweb("/path/to/repo", "repository name") 26 return hgweb("/path/to/repo", "repository name")
22 27
23 wsgicgi.launch(wsgiapplication(make_web_app)) 28 wsgicgi.launch(wsgiapplication(make_web_app))