Ejemplo n.º 1
0
def create_app(schedule_dir, template_dir):
    schedule = Schedule.from_directory(schedule_dir)
    resources = {'schedule': schedule,
                 'name_index': fm,
                 'LEGS': ALL_LEGS}
    subroutes = [('/', home, 'station_list.html'),
                 ('/<path:station_name>', get_stops, 'stop_times.html'),
                 ('/favicon.ico', not_found)]

    mako_response = MakoRenderFactory(template_dir)
    cc_mw = HTTPCacheMiddleware(max_age=30, must_revalidate=True)
    middlewares = [GzipMiddleware(), ProfilerMiddleware(), SimpleContextProcessor(LEGS=ALL_LEGS), cc_mw]
    subapp = Application(subroutes, resources, mako_response, middlewares,
                         error_handlers=err_handlers)

    routes = [('/', subapp), ('/v2/', subapp)]
    app = Application(routes, error_handlers=err_handlers)
    return app
Ejemplo n.º 2
0
def create_app(schedule_dir, template_dir):
    schedule = Schedule.from_directory(schedule_dir)
    resources = {"schedule": schedule, "name_index": NAME_MATCHER, "LEGS": ALL_LEGS}
    subroutes = [
        ("/", home, "station_list.html"),
        ("/favicon.ico", lambda: NotFound()),
        ("/<station_name>", get_stops, "stop_times.html"),
    ]

    mako_factory = MakoRenderFactory(template_dir)
    cc_mw = HTTPCacheMiddleware(max_age=30, must_revalidate=True)
    middlewares = [
        SimpleProfileMiddleware(),
        GetParamMiddleware(["sdate", "stime"]),
        SimpleContextProcessor(LEGS=ALL_LEGS),
        cc_mw,
    ]
    app = Application(subroutes, resources, mako_factory, middlewares)

    # routes = [('/', app), ('/v2/', app)]
    # app = Application(routes)
    return app
Ejemplo n.º 3
0
 def _check_integrity(self):
     try:
         self._schedule = Schedule.from_directory(target_dir_path)
     except Exception as e:
         # something's bork'd, add it to the report
         pass