如何在烧瓶路由中获取引导程序下降值

时间:2020-02-17 17:28:25

标签: flask twitter-bootstrap-3

我想从路由功能的下拉列表中提取选定的项目,然后将其发送给另一个功能。

我的html是这样的:

<div class="form-group">
  <label class="col-md-4 control-label" >Where do you want to go</label> 
    <div class="col-md-4 inputGroupContainer">
        <div class="dropdown" name = "destination_place" id="destination_place">
        <button class="btn btn-default dropdown-toggle" name = "destination_place" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
        <span id="selected" > Destination Place </span>
        <span class="caret"></span>
        </button>

        <ul class="dropdown-menu" aria-labelledby="dropdownMenu1"  >
        <li><a href="#" name = "destination_place" value = "Coorg">Coorg</a></li>
        <li><a href="#" name = "destination_place" value = "Mysore">Mysore</a></li>
        <li><a href="#" name = "destination_place" value = "Chikmagalur">Chikmagalur</a></li>
        <li><a href="#" name = "destination_place" value = "Hampi">Hampi</a></li>
        <li><a href="#" name = "destination_place" value = "Bangalore">Bangalore</a></li>
        <li><a href="#" name = "destination_place" value = "Udupi">Udupi</a></li>
        <li><a href="#" name = "destination_place" value = "Murudeshwar">Murudeshwar</a></li>

        </ul>
        </div>
    </div>
</div>

我的Flask函数是这样的:

@mod.route('/login/<int:userid>/', methods=['GET', 'POST'])
def mainplace(userid):
    userid = userid
    if request.method == 'POST':
        destination_place = request.form['destination_place']
        return redirect(url_for('itinerary.getMap', destination_place=destination_place))
    return render_template('user.html', userid = userid)

@mod.route('/getMap/<destinationplace>')
def getMap(destination_place):
    print("inside getMap routes",file=sys.stderr)
    dtn, details = itineary(destination_place)
    print(dtn, file=sys.stderr)
    print("Itinerary is " , details, file=sys.stderr)
    return render_template('direction.html', dtn=dtn, details = details)

我不确定我必须在哪里输入name =“ destination_place”或是否还有其他事情要做。我遇到这样的错误

werkzeug.exceptions.HTTPException.wrap.<locals>.newcls: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
At
destination_place = request.form['destination_place']

0 个答案:

没有答案