我很难找到匹配所有传入网址的通配符网址匹配模式。这只匹配一个只有主机名的URL:
import asyncio
from aiohttp import web
@asyncio.coroutine
def handle(request):
print('there was a request')
text = "Hello "
return web.Response(body=text.encode('utf-8'))
@asyncio.coroutine
def init(loop):
app = web.Application(loop=loop)
app.router.add_route('GET', '/', handle)
srv = yield from loop.create_server(app.make_handler(),
'127.0.0.1', 9999)
print("Server started at http://'127.0.0.1:9999'")
return srv
loop = asyncio.get_event_loop()
loop.run_until_complete(init(loop))
try:
loop.run_forever()
except KeyboardInterrupt:
pass
因此无论路径如何,它都应该在有请求时随时调用处理程序。如果是http://127.0.0.1:9999/或http://127.0.0.1:9999/test/this/test/
我在这里http://aiohttp.readthedocs.org/en/stable/web.html#aiohttp-web-variable-handler查找了正确的线索
没有成功答案 0 :(得分:28)
您可以使用WebView
来捕获所有网址。