Python 属性错误:';功能';对象没有属性';方法';对于if request.method==";POST";:

Python 属性错误:';功能';对象没有属性';方法';对于if request.method==";POST";:,python,python-3.x,methods,flask,Python,Python 3.x,Methods,Flask,正在运行Flask,它会给我一条错误消息,指向: if request.method == "POST": 这是我的错误: AttributeError: 'function' object has no attribute 'method' 我很困惑,因为我在另一个应用程序中使用了相同的代码,并且它可以工作。我是个十足的新手 这是app.py: from __future__ import print_function from flask import Flask, render_tem

正在运行Flask,它会给我一条错误消息,指向:

if request.method == "POST":
这是我的错误:

AttributeError: 'function' object has no attribute 'method'
我很困惑,因为我在另一个应用程序中使用了相同的代码,并且它可以工作。我是个十足的新手

这是app.py:

from __future__ import print_function
from flask import Flask, render_template, flash, request, url_for, redirect, session, g
import controllers
import config
from functools import wraps
import argparse
import json
import pprint
import requests
import sys
import urllib

# this client code can run on Python 2.x or 3.x.  Your imports can be
# simpler if you only need one of those.
try:
    # For Python 3.0 and later
    from urllib.error import HTTPError
    from urllib.parse import quote
    from urllib.parse import urlencode
except ImportError:
    # Fall back to Python 2's urllib2 and urllib
    from urllib2 import HTTPError
    from urllib import quote
    from urllib import urlencode

@app.route('/',  methods=["GET","POST"])
def main_route():
    if request.method == "POST":
        input_place = request.form['location']
        input_type = request.form['type']
        return render_template('index.html')
    return render_template('index.html')
这是我的index.html:

<form class="form-inline" method="post">
  <input type="text" class="form-control" placeholder="Zip Code or City" name="location_zip" value="{{request.form.location}}">
  <input type="text" class="form-control" placeholder="Type of Establishment" name="type_place" value="{{request.form.type}}">
  <input class="btn btn-link" type="submit" value="Submit">
</form>


flask.request是本地代理未绑定但requests.request是函数

flask.request是本地代理未绑定但requests.request是函数

您是否在该文件旁边的另一个项目或模块中命名了函数request烧瓶,然后烧瓶。无论什么,都可以减少出错的可能性,并/或将一个
打印(请求.\uuuu模块)
作为
主路径的第一行
。查看它是否输出除“werkzeug.local”以外的任何内容。确定您没有从请求导入请求执行
?您是否在该文件旁边的另一个项目或模块中命名了函数
请求
?否-除了此之外,还有其他内容将您的代码更改为使用
导入flask
,然后,
flask.which
,以减少出错的可能性和/或将
打印(请求.\uu模块\uuuu)
作为
主路径的第一行
。查看它是否输出除“werkzeug.local”以外的任何内容。是否确实没有从请求导入请求执行