Discuss / Python / 困扰了好久了,请帮助

困扰了好久了,请帮助

Topic source

c:\python36\awesome-python3-webapp\www>python app.py INFO:root:create database connection pool... INFO:root:init jinja2... INFO:root:set jinja2 template path: c:\python36\awesome-python3-webapp\www\templ ates INFO:root:and route GET / => index(request) INFO:root:add static /static/ => c:\python36\awesome-python3-webapp\www\static INFO:root:server started at http://127.0.0.1:9000... INFO:root:logger_factory&Request: GET / INFO:root:response_factory:Response handler... INFO:root:call with args: {} ERROR:aiohttp.server:Error handling request Traceback (most recent call last): File "C:\Users\huangxugang\AppData\Local\Programs\Python\Python35\lib\site-pac kages\aiohttp\web_protocol.py", line 381, in start resp = await self._request_handler(request) File "C:\Users\huangxugang\AppData\Local\Programs\Python\Python35\lib\site-pac kages\aiohttp\web_app.py", line 322, in _handle resp = await handler(request) File "C:\Users\huangxugang\AppData\Local\Programs\Python\Python35\lib\site-pac kages\aiohttp\web_middlewares.py", line 88, in impl return await handler(request) File "app.py", line 60, in logger return (await handler(request)) File "app.py", line 67, in response r = await handler(request) File "C:\Users\huangxugang\AppData\Local\Programs\Python\Python35\lib\site-pac kages\aiohttp\web_urldispatcher.py", line 161, in handlerwrapper result = await result File "c:\python36\awesome-python3-webapp\www\coroweb.py", line 145, in __call _ r = await self._func(kw) File "C:\Users\huangxugang\AppData\Local\Programs\Python\Python35\lib\asyncio\ coroutines.py", line 210, in coro res = func(*args, kw) File "c:\python36\awesome-python3-webapp\www\coroweb.py", line 22, in wrapper return func(args,*kw) TypeError: index() missing 1 required positional argument: 'request'

call with args 返回的参数为空,等问题

ERROR:aiohttp.server:Error handling request 这个不知道哪里出错了,在线等。

GZ丶辉

#3 Created at ... [Delete] [Delete and Lock User]

同学,我也再这里被卡了几天,终于被我发现了。参数为空,是因为handlers类中的User.FindAll查询不到。然后就应该回想这个方法的文件了,请看day8,ORM文件。(结束语。。。。。。。。廖老师。。。。。。。。。。。)

GZ丶辉

#4 Created at ... [Delete] [Delete and Lock User]

了解错了,一开始以为是语法的原因,原来应该是我的代码写错了

估计你是哪个地方写错了,我也是困扰了好久,今天发现是我has_request_arg的return缩进错了, 如果你的也有这个问题,我感觉肯能是这个函数有问题

好好检查has_request_arg 这个函数的返回应该是True

齐木大仙

#7 Created at ... [Delete] [Delete and Lock User]

也遇见了这个问题 原因在错误中这句话: TypeError: index() missing 1 required positional argument: 'request'

解决方案: 你应该是缺少 day7中的coroweb.py的129行到135行

在coroweb.py的129行到135行有关键的两行: if self._has_request_arg: kw['request'] = request


  • 1

Reply