forked from web2py/web2py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cgihandler.py
executable file
·63 lines (48 loc) · 1.43 KB
/
cgihandler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This file is part of the web2py Web Framework
Copyrighted by Massimo Di Pierro <[email protected]>
License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
This is a CGI handler for Apache
Requires apache+[mod_cgi or mod_cgid].
In httpd.conf put something like:
LoadModule cgi_module modules/mod_cgi.so
ScriptAlias / /path/to/cgihandler.py/
Example of httpd.conf ------------
<VirtualHost *:80>
ServerName web2py.example.com
ScriptAlias / /users/www-data/web2py/cgihandler.py/
<Directory /users/www-data/web2py>
AllowOverride None
Order Allow,Deny
Deny from all
<Files cgihandler.py>
Allow from all
</Files>
</Directory>
AliasMatch ^/([^/]+)/static/(.*) \
/users/www-data/web2py/applications/$1/static/$2
<Directory /users/www-data/web2py/applications/*/static/>
Order Allow,Deny
Allow from all
</Directory>
<Location /admin>
Deny from all
</Location>
<LocationMatch ^/([^/]+)/appadmin>
Deny from all
</LocationMatch>
CustomLog /private/var/log/apache2/access.log common
ErrorLog /private/var/log/apache2/error.log
</VirtualHost>
----------------------------------
"""
import os
import sys
import wsgiref.handlers
path = os.path.dirname(os.path.abspath(__file__))
os.chdir(path)
sys.path = [path] + [p for p in sys.path if not p == path]
import gluon.main
wsgiref.handlers.CGIHandler().run(gluon.main.wsgibase)