pgadmin4/web/pgAdmin4.py

51 lines
1.3 KiB
Python
Raw Normal View History

import os, sys, inspect
# We need to include the include/ directory in sys.path to ensure that we can
# fine everything we need when running in the standalone runtime. This tries
# to find the "real" path to use, regardless of any symlinks.
includedir = os.path.realpath(os.path.abspath(os.path.join(os.path.split(inspect.getfile(inspect.currentframe()))[0],"include")))
if includedir not in sys.path:
sys.path.insert(0, includedir)
# Rock n' roll...
import cherrypy
from time import time,ctime
2013-10-04 16:31:08 +00:00
# This is the main application class that we'll run under CherryPy.
class pgAdmin4(object):
2013-10-04 16:31:08 +00:00
# The main index page
@cherrypy.expose
def index(self):
output = """
Today is <b>%s</b>
<br />
<i>This is CherryPy-generated HTML.</i>
<br /><br />
<a href="http://www.pgadmin.org/">pgAdmin 4</a>""" % ctime(time())
return output
2013-10-04 16:31:08 +00:00
# A special URL used to "ping" the server
@cherrypy.expose
def ping(self):
return "PING"
# Start the web server. The port number should have already been set by the
# runtime if we're running in desktop mode, otherwise we'll just use the
# CherryPy default.
try:
cherrypy.server.socket_port = PGADMIN_PORT
except:
pass
try:
cherrypy.quickstart(pgAdmin4())
except IOError:
print "Unexpected error: ", sys.exc_info()[0]