seitime-frappe/public/html/web.py
2013-09-10 17:56:05 +05:30

71 lines
No EOL
1.5 KiB
Python
Executable file

#!/usr/bin/env python
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# MIT License. See license.txt
"""
return a dynamic page from website templates
all html pages related to website are generated here
"""
from __future__ import unicode_literals
import cgi, cgitb, os, sys
cgitb.enable()
# import libs
sys.path.append('..')
sys.path.append('../lib')
sys.path.append('../app')
import conf
session_stopped = """<!DOCTYPE html>
<html lang="en">
<head>
<title>%(title)s</title>
</head>
<body style="background-color: #eee; font-family: Arial, Sans Serif;">
<div style="margin: 30px auto; width: 500px; background-color: #fff;
border: 1px solid #aaa; padding: 20px; text-align: center">
<b>%(app_name)s: %(title)s</b>
<p>We will be back in a few moments.</p>
</div>
<!-- trace %(trace)s -->
</body>
</html>"""
def init():
import webnotes.handler
webnotes.handler.get_cgi_fields()
def respond():
import webnotes
import webnotes.webutils
import MySQLdb
try:
return webnotes.webutils.render(webnotes.form_dict.get('page'))
except webnotes.SessionStopped:
print "Content-type: text/html"
print
print session_stopped % {
"app_name": webnotes.get_config().app_name,
"trace": webnotes.getTraceback(),
"title": "Upgrading..."
}
except MySQLdb.ProgrammingError, e:
if e.args[0]==1146:
print "Content-type: text/html"
print
print session_stopped % {
"app_name": webnotes.get_config().app_name,
"trace": webnotes.getTraceback(),
"title": "Installing..."
}
else:
raise e
if __name__=="__main__":
init()
respond()