fluentpython / example-code

Example code for the book Fluent Python, 1st Edition (O'Reilly, 2015)
http://bit.ly/fluentpy
MIT License
5.56k stars 2.18k forks source link

18-asyncio/charfinder/http_charfinder.py 'Request' object has no Attribute 'GET' #31

Open ghost opened 5 years ago

ghost commented 5 years ago

the 18-asyncio-py3.7 folder doesn't have this file. but this file doesn't work in aiohttp3.5.4 with Python3.7.2 the Request object has no attribute 'GET', use query instead.

def home(request):
    try:
        query = request.GET.get('query', '').strip()
    except AttributeError:
        query = request.query.get('query', '').strip()
    print('Query: {!r}'.format(query))
wangzil88 commented 2 years ago

still not work in py3.97, should delete 'charset=UTF-8' in 'CONTENT_TYPE = 'text/html; charset=UTF-8'