2016-09-05 60 views
1

我收到錯誤「AttributeError:'請求'對象沒有屬性'params'」在python3,ubuntu上的獵鷹庫中。AttributeError:'請求'對象沒有屬性'params'

請求URL = 127.0.0.1:8000/user?name=abc

from wsgiref import simple_server 
import falcon 

class user(object): 
    def on_get(self, req, resp): 
     print(req.params['name']) 

api = application = falcon.API() 

usr = user() 
api.add_route('/user', usr) 

if __name__ == '__main__': 
    http = simple_server.make_server('127.0.0.10', 8000, api) 
    http.serve_forever() 

在上面的代碼我無法訪問如果您正在使用1.0版本req.params

+0

你使用的是什麼版本? – joarleymoraes

+0

Python 3.4,Falcon 1.0和Ubuntu 14 – pikkupr

回答

0

,是請注意以下重大更改的:

An option was added to toggle automatic parsing of form params. Falcon will no longer automatically parse, by default, requests that have the content type "application/x-www-form-urlencoded"...

Applications that require this functionality must re-enable it explicitly, by setting a new request option that was added for that purpose, per the example below:

app = falcon.API() 
app.req_options.auto_parse_form_urlencoded = True 

https://github.com/falconry/falcon/blob/master/CHANGES.rst

相關問題