Exemplo n.º 1
0
async def req1(req):
    print("req1", req.url)
    if '/get/' in req.path or '/do/' in req.path or '/post/' in req.path:
        return
    ext = req.path.split('.')[-1]
    if ext in ('mp3', 'js', 'jpg', 'css', 'ttf', 'png', 'woff', 'woff2', 'ico',
               'gif', 'map', 'mem', 'pck', 'mp4', 'csv'):
        pfil = './web' + req.path
        return await response_file(
            location=pfil, headers={"cache-control": "public,max-age=216000"})
    elif ext in 'html':
        pfil = './web' + req.path
        tmp = Render(pfil)
        rtn = await tmp.parse()
        return response_html(
            body=rtn, headers={"cache-control": "public,max-age=216000"})
    elif ext in 'py':
        pfil = '.' + req.path
        # /w*.py y /vs_widgets will be served not server side .py
        if (req.path[:2] == '/w'
                or "/vs_widgets" in req.path) and ".." not in req.path:
            return await response_file(
                pfil, headers={"cache-control": "public,max-age=216000"})
        else:
            return response_text("error")
    else:
        return response_text("error")
Exemplo n.º 2
0
async def info(request):
    """Return an HTML page with a list of all add-ons."""
    addons = ''
    with _LOCK:
        for addon in sorted(_LIST, key=lambda e: e['name']):
            addons += _LI_TEMPLATE.format(
                name=escape_html(addon['name']),
                description=escape_html(addon['description']),
                author=escape_html(addon['author']),
                homepage=escape_html(addon['homepage_url']),
            )

    return response_html(_HTML.format(css=_CSS, addons=addons))
Exemplo n.º 3
0
async def route1(req, tag):
    print(req)
    print('module', tag)
    print('params', req.raw_args)
    if '&' in tag:
        module = tag.split('&')[0]
    else:
        module = tag
    pfil = './web/' + module + '.html'
    tmp = Render(pfil)
    rtn = await tmp.parse()
    return response_html(body=rtn,
                         headers={"cache-control": "public,max-age=216000"})
Exemplo n.º 4
0
async def index(request: Request):
    return response_html(open("./dist/index.html", "r").read())