Hi. here is my code.please help how use aiphttp handle http GET request.
from aiohttp import web
import asyncio
@asyncio.coroutine
def AppLogin(request):
## here how to i get a dictionary {'uuid':'abc','key':"123456"} from url "http://127.0.0.1:9000/iot/auth/app/?uuid=abc&key=123456"
return web.json_response({"req":str(get_params)})
@asyncio.coroutine
def create_app(loop):
app = web.Application(loop=loop)
app_resource = app.router.add_resource('/iot/app/auth/',name='applogin')
app_resource.add_route('GET',AppLogin)
return app
# curl "http://127.0.0.1:9000/iot/auth/app/?uuid=abc&key=123456"
@yjdwbj Please ask usage questions on support forum.
With aiohttp>=1.1 You can get query string params using request.rel_url.query:
@asyncio.coroutine
def AppLogin(request):
uuid = request.rel_url.query['uuid']
...
@asvetlov access of query parameters indeed not covered in Server Tutorial
@rutsky please create a PR for tutorial. This data should be available as request.GET too but I doubt if we should promote the property.
Maybe better to deprecate .GET and .POST and promote .rel_url.query, .post() and .multipart() as prime API?
@asvetlov .query_params, .data and .multipart is good choice I think.
we have .query, .post() and .multipart
@rutsky good point
@fafhrd91 let's keep the issue open until I'll fix tutorial by mentioning request.rel_url.query in it.
@asvetlov I tried to use .rel_url and ergonomics is not good. I think we should provide
query, query_string, etc as a first class attributes of request object.
N.P. we could remove deprecation marks and expose aliases for most useful properties.
I volunteer for PR for it if nobody object.
Done in aiohttp 2.1 I believe
This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a [new issue] for
related bugs.
If you feel like there's important points made in this discussion,
please include those exceprts into that [new issue].
Most helpful comment
@yjdwbj Please ask usage questions on support forum.
With aiohttp>=1.1 You can get query string params using
request.rel_url.query:@asvetlov access of query parameters indeed not covered in Server Tutorial