web/code-fapws3.wsgi

Sat Jun 20 20:44:03 2009 +0900

author
hattori@www.hexacosa.net
date
Sat Jun 20 20:44:03 2009 +0900
changeset 6
c6da061b21c4
permissions
-rwxr-xr-x

profiling for web application

     1 import web
     2 import fapws._evwsgi as evwsgi
     3 from fapws import base
     6 DBPATH = '/var/www/app/hello/hello.sqlite'
     7 TEMPLATE_PATH = '/var/www/templates/'
     9 urls = (
    10     '/', 'index',
    11     '/(.*)', 'hello',
    12 )
    14 render = web.template.render(TEMPLATE_PATH)
    15 application = web.application(urls, globals()).wsgifunc()
    16 db = web.database(dbn='sqlite', db=DBPATH)
    18 class hello:
    19     def GET(self, username):
    20         users = db.select('hellouser', where="name = '%s'" % username)
    21         isFound = False
    22         for u in users:
    23             if u.name == username:
    24                 isFound = True
    25         if not isFound:
    26             db.query("INSERT INTO hellouser (name) VALUES ('%s')" % username)
    27         return render.hello(username, isFound)
    29 class index:
    30     def GET(self):
    31         return "Hello web.py"
    33 if __name__ == '__main__':
    34     application = web.application(urls, globals()).wsgifunc()
    35     evwsgi.start("0.0.0.0", 8080)
    36     evwsgi.set_base_module(base)
    37     evwsgi.wsgi_cb(("", application))
    38     evwsgi.run()

mercurial