Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.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
Flask 如何使用GET/POST发送GET到烧瓶_Flask_Http Post_Jinja2_Get Request_Python Requests Html - Fatal编程技术网

Flask 如何使用GET/POST发送GET到烧瓶

Flask 如何使用GET/POST发送GET到烧瓶,flask,http-post,jinja2,get-request,python-requests-html,Flask,Http Post,Jinja2,Get Request,Python Requests Html,在templates文件夹中,我有index.html和template.html 我正在尝试从index.html中的表单获取数据,处理数据并将结果发布到template.html中,显示为 index.html: <form method="POST"> <select class="browser-default custom-select" name="regions_brato"> <option selected>Open this

在templates文件夹中,我有index.html和template.html 我正在尝试从index.html中的表单获取数据,处理数据并将结果发布到template.html中,显示为

index.html:

<form method="POST">
     <select class="browser-default custom-select" name="regions_brato">
  <option selected>Open this select menu</option>
  {% for each,key in new_dict.items() %}
  <option value="{{each}}">{{each}}</option>
  {% endfor %}
</select>

     <select name="list_status">
  {% for key in listStatus %}
    <option value="{{key}}">{{key}}</option>
  {% endfor %}
</select>

   <input type="submit">
</form>

有人能告诉我,我到底把GET/POST请求和任何可能的解决方案弄糟了哪里吗?

我不知道你是否弄糟了什么,但我知道如果没有帮助,你无法测试发布,它是不可见的。你需要像邮递员或服务器这样的应用程序。可能就是这样。

我目前正试图在AWS EC2实例上运行此项目。尽管我做了很多尝试,但在进行POST请求时仍然会出现500个内部错误。。
..
<body>
  {% for each,key in res.items() %}
  <p>{{each}}</p>
  {% endfor %}

</body>
..
@application.route('/', methods=['GET', 'POST'])
def form():
    listStatus = ['en', 'fr', 'bg']
    new_dict = {}

    with open('fr.json') as json_file:

        data = json.load(json_file)
        for each in data:
            new_dict.setdefault(each['admin'], []).append(each['city'])

    if request.method == 'GET':
        return render_template('index.html', listStatus=listStatus, default="en", new_dict=new_dict)
    else:
        return redirect(url_for('template'))


@application.route('/template')
def template():
    region = request.form["regions_brato"]
    lang = request.form["list_status"]
    res = get_feel(region, lang, 30)
    return render_template("template.html", res=res)