पर मुझे एक वाइल्डकार्ड यूआरएल मिलान पैटर्न खोजने में परेशानी है जो सभी आने वाले यूआरएल से मेल खाता है।Asyncio और aiohttp मार्ग सभी यूआरएल पथ हैंडलर
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 सही सुराग