Beispiel #1
0
    async def get(self, path, *args, **kwargs):
        if path in _APPS:
            app, context = _APPS[path]
        else:
            if path.endswith('yml') or path.endswith('.yaml'):
                from lumen.config import config
                from lumen.command import build_single_handler_application as build_lumen
                config.dev = True
                app = build_lumen(path, argv=None)
            else:
                app = build_single_handler_application(path)
            context = ApplicationContext(app, url=path)
            context._loop = tornado.ioloop.IOLoop.current()
            _APPS[path] = (app, context)

        self.application_context = context

        session = await self.get_session()

        page = server_html_page_for_session(
            session,
            resources=RESOURCES,
            title=session.document.title,
            template=session.document.template,
            template_variables=session.document.template_variables
        )

        self.set_header("Content-Type", 'text/html')
        self.write(page)
Beispiel #2
0
 async def handle(self, body: bytes) -> None:
     session = await self._get_session()
     page = server_html_page_for_session(session,
                                         resources=self.resources(),
                                         title=session.document.title,
                                         template=session.document.template,
                                         template_variables=session.document.template_variables)
     await self.send_response(200, page.encode(), headers=[(b"Content-Type", b"text/html")])
Beispiel #3
0
    def get(self, *args, **kwargs):
        session = yield self.get_session()
        page = server_html_page_for_session(session,
                                            resources=self.application.resources(),
                                            title=session.document.title,
                                            template=session.document.template,
                                            template_variables=session.document.template_variables)

        self.set_header("Content-Type", 'text/html')
        self.write(page)
    def get(self, *args, **kwargs):
        session = yield self.get_session()

        page = server_html_page_for_session(session.id, self.application.resources(),
                                            title=session.document.title,
                                            template=session.document.template,
                                            template_variables=session.document.template_variables)

        self.set_header("Content-Type", 'text/html')
        self.write(page)
Beispiel #5
0
    async def handle(self, body):

        scope = self.scope
        session = await self._get_session()
        res = Resources(mode="server", root_url="/", path_versioner=StaticHandler.append_version)
        import threading
        page = server_html_page_for_session(session,
                                            resources=res,
                                            # title=session.document.title,
                                            title=str(session._id) + threading.current_thread().name,
                                            template=session.document.template,
                                            template_variables=session.document.template_variables)

        await self.send_response(200, page.encode(), headers=[
            (b"Content-Type", b"text/html"),
        ])
Beispiel #6
0
    async def get(self, *args, **kwargs):
        session = await self.get_session()

        mode = settings.resources(default="server")
        css_files = session.document.template_variables.get('template_css_files')
        resource_opts = dict(mode=mode, extra_css_files=css_files)
        if mode == "server":
            resource_opts.update({
                'root_url': self.application._prefix,
                'path_versioner': StaticHandler.append_version
            })
        resources = PanelResources(**resource_opts)

        page = server_html_page_for_session(
            session, resources=resources, title=session.document.title,
            template=session.document.template,
            template_variables=session.document.template_variables
        )

        self.set_header("Content-Type", 'text/html')
        self.write(page)