examples/hgweb_wsgi.py

1
"""WSGI application serving the Mercurial wire protocol.
2
 
3
Reads its hgweb config from $HGWEB_CONFIG (default /etc/hgweb.config),
4
so one copy of this file serves any number of instances. Run under any
5
WSGI server, e.g.:
6
 
7
    HGWEB_CONFIG=/srv/code.example.org/config/hgweb.config \
8
        gunicorn --workers 2 --bind 127.0.0.1:8420 hgweb_wsgi:application
9
 
10
Only requests with a ?cmd= parameter should be routed here (see
11
nginx.conf / apache.conf); the HTML UI this app could also serve is
12
never exposed.
13
"""
14
 
15
import os
16
 
17
from mercurial.hgweb import hgweb
18
 
19
application = hgweb(os.environ.get("HGWEB_CONFIG", "/etc/hgweb.config").encode())