Python TypeError:uuu init_uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu;方法';

Python TypeError:uuu init_uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu;方法';,python,flask,Python,Flask,嗯,我正在写一个Flask项目,但是当我尝试python manage.py 回溯告诉我: Traceback (most recent call last): File "manage.py", line 5, in <module> from app import db,create_app File "/home/humbert/2017-sharing-backend/sharing/app/__init__.py",

嗯,我正在写一个Flask项目,但是当我尝试
python manage.py

回溯告诉我:

Traceback (most recent call last):
  File "manage.py", line 5, in <module>
    from app import db,create_app
  File "/home/humbert/2017-sharing-backend/sharing/app/__init__.py", line 42, in <module>
    app.register_blueprint(main_blueprint, url_prefix='/main')
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/app.py", line 64, in wrapper_func
    return f(self, *args, **kwargs)
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/app.py", line 951, in register_blueprint
    blueprint.register(self, options, first_registration)
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/blueprints.py", line 154, in register
    deferred(state)
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/blueprints.py", line 173, in <lambda>
    s.add_url_rule(rule, endpoint, view_func, **options))
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/blueprints.py", line 76, in add_url_rule
    view_func, defaults=defaults, **options)
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/app.py", line 64, in wrapper_func
    return f(self, *args, **kwargs)
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/app.py", line 1043, in add_url_rule
    rule = self.url_rule_class(rule, methods=methods, **options)
TypeError: __init__() got an unexpected keyword argument 'method'

我真的需要一些帮助,谢谢

我也有类似的问题。我的代码里有一行

@路由('//delete',方法=('POST'))

关键字method需要更改为methods(带有s)

我在代码中遇到了类似的问题,只需将关键字“method”更改为“methods”:


如果代码中还剩下一些东西,则必须调试代码。在我的例子中,我错过了一个必须添加的
id
属性。在尝试处理@app.route('/todos/create',method=['POST'])时,我的todo flask项目也有同样的问题。您的答案通过添加's':@app.route('/todos/create',methods=['POST'])帮助我解决了这个问题:@app route('/todos/create',methods=['POST'])谢谢Nicholas Harder。当我能看到老的SO帖子,并得到正确的答案时,总是很好,就像这样。。。愚蠢的打字错误,派林并没有抓住烧瓶里的很多东西,因为它是…你只是重复了被接受的答案,将近五个月后!为什么?英雄联盟
from .main import main as main_blueprint
app.register_blueprint(main_blueprint, url_prefix='/main')

from .auth import auth as auth_blueprint
app.register_blueprint(auth_blueprint, url_prefix="/auth")

from . import views
@app.route('/login', methods = ['GET', 'POST'])