-
Notifications
You must be signed in to change notification settings - Fork 43
/
app.py
74 lines (59 loc) · 2.03 KB
/
app.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
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/python
import logging
import new
import os
import pickle
import cgi
import sys
import traceback
import urlparse
import types
import wsgiref.handlers
import re
import posixpath
import urllib
from google.appengine.api import urlfetch
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import template
_LOCAL_ = os.environ[ 'SERVER_SOFTWARE' ].startswith( 'Development' )
_DEBUG_ = False or _LOCAL_
_CACHE_ = False
sys.path.append( 'pyl' )
import jinja2 as jinja2_
jinja2 = jinja2_.Environment( loader=jinja2_.FileSystemLoader( 'jinja2-assets' ) )
from gist_it import appengine as gist_it_appengine
gist_it_appengine.jinja2 = jinja2
class RequestHandler( webapp.RequestHandler ):
def url_for( self, *arguments ):
parse = urlparse.urlparse( self.request.url )
path = ''
if len( arguments ):
path = posixpath.join( *arguments )
return str( urlparse.urlunparse( ( parse.scheme, parse.netloc, path, '', '', '' ) ) )
def render_template( self, template_name, **arguments ):
self.response.out.write( jinja2.get_template( template_name ).render( dispatch=self, **arguments ) )
class dispatch_index( RequestHandler ):
def get( self ):
self.render_template( 'index.jinja.html' )
class dispatch_test( RequestHandler ):
def get( self ):
return gist_it_appengine.dispatch_test( self )
class dispatch_test0( RequestHandler ):
def get( self ):
return gist_it_appengine.dispatch_test0( self )
class dispatch_gist_it( RequestHandler ):
def get( self, location ):
return gist_it_appengine.dispatch_gist_it( self, location )
wsgi_application = webapp.WSGIApplication( [
( r'/', dispatch_index ),
( r'/test', dispatch_test ),
( r'/test0', dispatch_test0 ),
( r'/xyzzy/(.*)', dispatch_gist_it ),
( r'(.*)', dispatch_gist_it ),
], debug=_DEBUG_ )
def main():
run_wsgi_app( wsgi_application )
if __name__ == '__main__':
main()