1
我想要做的是傳遞函數參數中的日期,然後處理輸入。這裏的功能它如何在URL中使用*斜槓*傳遞參數?
@HR.route('/confirm_sickLeave/<date>/<user>', methods=['GET', 'POST'])
def confirm_sickLeave(user,date):
u = User.query.filter_by(username=user.username).first()
print u
us = UserStatistics.filter_by(userId=u.id).first()
temp = us.slDates
dates = temp.keys()
for a in dates:
if a == date:
temp['date'] = True
flash('Date Confirmed.')
return redirect(url_for('.approval_of_leaves'))
return redirect(url_for('.approval_of_leaves'))
現在,我的問題是我無法通過我的函數的值。原因是我的輸入dates
在其中有斜線(/
)。讓我告訴你:
HTML:
{% for u in all_users %}
## Returns all the dates applied by the user (it's in dict format)
{% set user_info = u.return_sickLeaves(u.username) %}
{% for us in user_info %}
<tr>
<td> {{ u.username }} </td>
<td> {{ us|e }} </td>
{% if us.value|e == True %}
<td class="success">Confirmed</td>
{% else %}
<td class="warning">Pending..</td>
{% endif %}
<td><a href = "{{ url_for('HR.confirm_sickLeave', user=u.username, date= us|e) }}">Confirm</a>
<a href = "#">Deny</a>
</td>
{% endfor %}
</tr>
{% endfor %}
現在,當我嘗試點擊確認按鈕,我得到的迴應是Error 404 not found
。 404錯誤的網址是:http://localhost:5000/confirm_sickLeave/02/01/2015%3B02/02/2015/seer
有沒有其他方法可以做?感謝您的貢獻。 :)
格式化網址的日期,因此它是'2015-02-02'。 – 2015-02-10 11:45:30
不知道它如何在Python中工作,但如果你需要讀取值,你可以編碼/到%09然後發送。看網址編碼 – 2015-02-10 11:54:02