Python POST方法不适用于烧瓶应用程序

Python POST方法不适用于烧瓶应用程序,python,html,python-3.x,jinja2,Python,Html,Python 3.x,Jinja2,我正在尝试运行一个基于多个简单教程的简单Flask应用程序。我的目标是完成一个完整的教程,并使用代码构建一个连接到SQL server数据库的搜索web应用程序 但是,当我尝试运行代码并提供整数输入时,POST方法不起作用,因此它不会返回指定的{{value}} 我尝试了添加和删除几个组件:在HTML上添加action='/',并尝试在没有它的情况下运行代码。那没什么区别 我已经有了方法=['GET','POST'] 我甚至尝试了{{url\u for('/')}},但这只给了我一个内部服务器错

我正在尝试运行一个基于多个简单教程的简单Flask应用程序。我的目标是完成一个完整的教程,并使用代码构建一个连接到SQL server数据库的搜索web应用程序

但是,当我尝试运行代码并提供整数输入时,POST方法不起作用,因此它不会返回指定的
{{value}}

我尝试了添加和删除几个组件:在HTML上添加
action='/'
,并尝试在没有它的情况下运行代码。那没什么区别

我已经有了
方法=['GET','POST']

我甚至尝试了
{{url\u for('/')}}
,但这只给了我一个内部服务器错误

from flask_sqlalchemy import SQLAlchemy

    app = Flask(__name__)

    @app.route('/hello')
    def hello():
        return "My flask app"

    @app.route('/', methods=["GET", "POST"])
    def home():
        if request.method == "POST":
            value = int(request.form["number"])
            add_one = value + 1
            return render_template('index.html', string="WORLD!", value=add_one)
        return render_template('index.html', string="WORLD!")


    if __name__ == "__main__":
        app.run()
HTML:
你好,{{string}}

提交 计算的数字为{value}


运行代码时,我的应用程序会成功呈现,但在提交数字时,服务器不会注册输入


我甚至没有收到一个错误。我在终端中看到的只是通过删除
HTML
中表单的
onsubmit=“return false;”“
属性来获取/HTTP/1.1”200。 重新启动应用程序并重新加载
HTML
。 它应该是有效的

    HTML:

    <body>
        <div class="container">
          <h1>Hello, {{string}}</h1>
          <br>
            <form action='/' role="form" method="post" onsubmit="return false;">
              <div class="form-group">
                  <input type="number" class="form-control" name="number" placeholder="Enter a number" required>
              </div>
              <button type="submit" class="btn btn-default">Submit</button>
          </form>
          <p>The calculated number is {{value}}</p>
        <br>
        </div>
        <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
        <script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
      </body>