예제 #1
0
def make_app():
    router = Router()

    router.register('/api/models/(?P<model>[^/]+)/', ModelHandler)

    urls = [
        (r'/', MainHandler),
        (r'/register/', RegisterHandler),
        (r'/api/', ApiHandler),
        (r'/api/register/', RegisterHandler),
        (r'/api/model_descriptions/', ModelDescriptionsHandler),
        (r'/api/sql/', SqlHandler),
        (r'/api/messages/', MessageHandler),
        (r'/api/file_upload/', MediaFileUploadHandler),
        (r'/api/image_resize/', ImageResizeHandler),
        (r'/media/(.*)', tornado.web.StaticFileHandler, {'path': settings.MEDIA_ROOT}),
    ]
    urls += router.urls

    if settings.MEDIA_STORAGE == media.MEDIA_STORAGE_DEFAULT:
        urls.append((r'/media/(.*)', tornado.web.StaticFileHandler, {'path': settings.MEDIA_ROOT}))

    return tornado.web.Application(
        handlers=urls,
        debug=settings.DEBUG,
        default_handler_class=NotFoundHandler,
        template_path=os.path.join(settings.BASE_DIR, 'templates')
    )
예제 #2
0
def make_app():
    router = Router()

    router.register('/api/models/(?P<model>[^/]+)/',
                    view_handler(ModelViewSet))

    urls = [
        (r'/', TemporaryRedirectHandler, {
            'url': "/api/"
        }),
        (r'/register/', view_handler(RegisterView)),
        (r'/api/', view_handler(ApiView)),
        (r'/api/register/', view_handler(RegisterView)),
        (r'/api/model_descriptions/', view_handler(ModelDescriptionView)),
        (r'/api/sql/', view_handler(SqlView)),
        (r'/api/messages/', view_handler(MessageView)),
        (r'/api/file_upload/', view_handler(FileUploadView)),
        (r'/api/image_resize/', view_handler(ImageResizeView)),
        (r'/media/(.*)', tornado.web.StaticFileHandler, {
            'path': settings.MEDIA_ROOT
        }),
    ]
    urls += router.urls

    if settings.MEDIA_STORAGE == media.MEDIA_STORAGE_FILE:
        urls.append((r'/media/(.*)', tornado.web.StaticFileHandler, {
            'path': settings.MEDIA_ROOT
        }))

    return tornado.web.Application(handlers=urls,
                                   debug=settings.DEBUG,
                                   default_handler_class=NotFoundHandler,
                                   template_path=os.path.join(
                                       base_settings.BASE_DIR, 'templates'),
                                   autoreload=settings.DEBUG)
예제 #3
0
def make_app():
    router = Router()

    router.register('/api/models/(?P<model>[^/]+)/', view_handler(ModelViewSet))

    urls = [
        (r'/', TemporaryRedirectHandler, {'url': '/api/'}),
        (r'/register/', view_handler(RegisterView)),
        (r'/api/', view_handler(ApiView)),
        (r'/api/register/', view_handler(RegisterView)),
        (r'/api/model_descriptions/', view_handler(ModelDescriptionView)),
        (r'/api/sql/', view_handler(SqlView)),
        (r'/api/messages/', view_handler(MessageView)),
        (r'/api/file_upload/', view_handler(FileUploadView)),
        (r'/api/image_resize/', view_handler(ImageResizeView)),
        (r'/api/reload/', view_handler(ReloadView)),
        (r'/api/proxy_request/', view_handler(ProxyRequestView)),
        (r'/media/(.*)', tornado.web.StaticFileHandler, {'path': settings.MEDIA_ROOT}),
        (r'/api/external_auth/login/(?P<app>[^/]+)/', view_handler(ExternalAuthLoginView)),
        (r'/api/external_auth/complete/(?P<app>[^/]+)/', view_handler(ExternalAuthCompleteView)),
    ]
    urls += router.urls

    if settings.MEDIA_STORAGE == media.MEDIA_STORAGE_FILE:
        urls.append((r'/media/(.*)', tornado.web.StaticFileHandler, {'path': settings.MEDIA_ROOT}))

    if settings.THREADS is not None:
        set_max_workers(settings.THREADS)

    return tornado.web.Application(
        handlers=urls,
        debug=settings.DEBUG,
        default_handler_class=NotFoundHandler,
        template_path=os.path.join(base_settings.BASE_DIR, 'templates'),
        autoreload=settings.DEBUG,
        cookie_secret=settings.TOKEN
    )