analytics / main.py

#!/usr/bin/env python

import tornado.web, tornado.template, googleanalytics, widget
from googleanalytics import Page

try: import secret_config as config
except: import config

try: import json
except: from django.utils import simplejson as json

class HomePage(Page):
    URL = r'/'
    def get(self):
        self.render('template/index.html',
            login = config.TORNADO_INIT['login_url'])

# Get the list of URLs for all handlers
import inspect
def urls(module):
    '''Given [(key, item)], returns [(url, class)] with RequestHandlers'''
    return list((cls.URL, cls) for key, cls in module
        if inspect.isclass(cls) and hasattr(cls, 'URL')
        and issubclass(cls, tornado.web.RequestHandler))

application = tornado.web.Application(
    urls(globals().items()) +
    urls(inspect.getmembers(googleanalytics)) +
    urls(inspect.getmembers(widget)),
**config.TORNADO_INIT)

if __name__ == "__main__":
    import tornado.httpserver, tornado.ioloop, tornado.options
    tornado.options.parse_command_line()
    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(config.PORT)
    tornado.ioloop.IOLoop.instance().start()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.