コード例 #1
0
ファイル: static_handler_test.py プロジェクト: jagguli/aioweb
    def test_static_file(self):
        router = Router()
        router.add_handler("/static/(.*)$", self.handler, 
                           dict(staticroot="static", baseurl="/static/"))
        with run_test_server(self.loop, router=router) as httpd:
            url = httpd.url('static', 'test.js')
            meth = 'get'
            r = self.loop.run_until_complete(
                client.request(meth, url))
            content1 = self.loop.run_until_complete(r.read())
            content = content1.decode()

            self.assertEqual(r.status, 200)
            self.cookies = r.cookies
            r.close()
コード例 #2
0
ファイル: routes.py プロジェクト: jagguli/aioweb
def get_routes(router=None):
    from aioweb.config import config
    if not router:
        router = Router()
    router.add_handler('/favicon.ico', StaticFileHandler,
                       dict(staticroot=config['default']['staticroot']))
    router.add_handler('/dojo/', StaticFileHandler,
                       dict(staticroot=config['default']['dojo'],
                            baseurl="/dojo/"))
    router.add_handler('/jasmine/', StaticFileHandler,
                       dict(staticroot=config['default']['jasmine'],
                            baseurl='/jasmine/'))
    router.add_handler('/intern/', StaticFileHandler,
                       dict(staticroot=config['default']['intern'],
                            baseurl='/intern/'))

    app_routes = Router("/", (
        ("/$", HomeHandler),
        ("/(supplementme)/(.*).js", StaticFileHandler, dict(
            staticroot=join(dirname(__file__), 'js'),
            baseurl="/supplementme/")),
        ("/(supplementme)/(.*).html", StaticFileHandler, dict(
            staticroot=join(dirname(__file__), 'html'),
            baseurl="/supplementme/")),
        ("/(supplementme)/(.*).css", StaticFileHandler, dict(
            staticroot=join(dirname(__file__), 'css'),
            baseurl="/supplementme/")),
        ("/auth/login$", AuthHandler),
        ("/meal/{0,1}(.*)$", MealHandler),
        ("/nutrients/{0,1}(.*)$", NutrientHandler),
        ("/food/{0,1}(.*)$", FoodHandler),
        ("/test/{0,1}(.*)$", WidgetTestHandler))
    )
    router.add_handler('/', app_routes)
    return router