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")
async def postinfo(req, tag): if Develop: rtn = mreq.postinfo(req.args, tag, req.path, req.query_string, req.json) else: job = Q_normal.enqueue_call(func=mreq.postinfo, args=(req.args, tag, req.path, req.query_string, req.json), timeout=20) while True: await sleep(.01) if job.result is not None: rtn = job.result break return response_text(rtn)
async def get_license(request, addon_id): """Get the license text for a specific add-on.""" license_url = None with _LOCK: for addon in _LIST: if addon['id'] == addon_id: license_url = addon['license_url'] break if not license_url: return response_empty(status=404) try: r = requests.get(license_url) return response_text(r.text) except requests.exceptions.RequestException: return response_empty(status=500)
async def route1(req, tag): return response_text(tag)
async def index(_r): print(app.proxy.methods.keys()) print(app.proxy.properties.keys()) print(app.proxy.signals) return response_text('', 204)
async def pass_(_r): return response_text('', 204)
async def play(_r): await app.proxy.PlayPause() return response_text('', 204)