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