Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python request.method默认进入烧瓶_Python_Post_Flask - Fatal编程技术网

Python request.method默认进入烧瓶

Python request.method默认进入烧瓶,python,post,flask,Python,Post,Flask,我在Flask中创建了一个表单,希望提交某些需要处理的值。但是使用的方法被默认为GET,即使我在表单中已将该方法指定为post 以下是相关代码文件的详细信息: app.py test.html <form method="post" class="text-center" style="color: #757575;" action=""> <div class="form-row"> <di

我在Flask中创建了一个表单,希望提交某些需要处理的值。但是使用的方法被默认为GET,即使我在表单中已将该方法指定为post

以下是相关代码文件的详细信息: app.py

test.html

<form method="post" class="text-center" style="color: #757575;" action="">

                <div class="form-row">
                    <div class="col">
                        <!-- First name -->
                        <div class="md-form">
                            <input type="text" name="firstname" value="{{request.form.firstname}}" class="form-control">
                            <label for="materialRegisterFormFirstName">First name</label>
                        </div>
                    </div>
                    <div class="col">
                        <!-- Last name -->
                        <div class="md-form">
                            <input type="text" name="lastname" value="{{request.form.lastname}}" class="form-control">
                            <label for="materialRegisterFormLastName">Last name</label>
                        </div>
                    </div>
                </div>

                <!-- File Upload -->
                <div class="md-form">
                    <input type="file" id="fileupload" class="form-control">


                </div>

                <input class="btn btn-info btn-block" type="submit" value="Submit">
            </form>

名字
姓
加载127.0.0.1:5000/测试时,该方法默认为post,响应“错误”。方法始终为GET


<form method="post" class="text-center" style="color: #757575;" action="/test" method="post">

            <div class="form-row">
                <div class="col">
                    <!-- First name -->
                    <div class="md-form">
                        <input type="text" name="firstname" value="{{request.form.firstname}}" class="form-control">
                        <label for="materialRegisterFormFirstName">First name</label>
                    </div>
                </div>
                <div class="col">
                    <!-- Last name -->
                    <div class="md-form">
                        <input type="text" name="lastname" value="{{request.form.lastname}}" class="form-control">
                        <label for="materialRegisterFormLastName">Last name</label>
                    </div>
                </div>
            </div>

            <!-- File Upload -->
            <div class="md-form">
                <input type="file" id="fileupload" class="form-control">


            </div>

            <input class="btn btn-info btn-block" type="submit" value="Submit">
        </form>
名字 姓
通过在action属性中添加“route”并定义表单提交的方法,您可以执行所需的目标。

我事先添加了method=“post”属性。现在,即使在我定义了action=“/test”之后,该方法仍然是GET
<form method="post" class="text-center" style="color: #757575;" action="/test" method="post">

            <div class="form-row">
                <div class="col">
                    <!-- First name -->
                    <div class="md-form">
                        <input type="text" name="firstname" value="{{request.form.firstname}}" class="form-control">
                        <label for="materialRegisterFormFirstName">First name</label>
                    </div>
                </div>
                <div class="col">
                    <!-- Last name -->
                    <div class="md-form">
                        <input type="text" name="lastname" value="{{request.form.lastname}}" class="form-control">
                        <label for="materialRegisterFormLastName">Last name</label>
                    </div>
                </div>
            </div>

            <!-- File Upload -->
            <div class="md-form">
                <input type="file" id="fileupload" class="form-control">


            </div>

            <input class="btn btn-info btn-block" type="submit" value="Submit">
        </form>