Best way to submit UL via POST?

后端 未结 4 1199
春和景丽
春和景丽 2020-12-18 04:38

Quick question...

I have an input box that upon key enter, adds the value to an unordered list. How would I pass this unordered list to jquery post? I\'m using the f

4条回答
  •  鱼传尺愫
    2020-12-18 05:28

    Something similar works with Pythons Flask, but you have to use request.form.getlist(arg) instead of just "get".

    In fruits.html:

    • Apple
    • Pear
    • Banana

    In app.py:

    @app.route('/fruits', methods=['GET', 'POST'])
    def get_fruits():
    if request.method == 'POST':
        fruits = request.form.getlist("fruits")
        print fruits
    return render_template(fruits.html)
    

    This will print out:

    ['Apple', 'Pear', 'Banana']
    

提交回复
热议问题