简而言之,python Flask 是我使用的网络托管工作台,我正在尝试创建一个不会出现在您的历史记录中的输入表单。这是我的表单html:<form name="ViewWindow" action="/home/ViewWindow/ViewWindowResult/"> <input name="url" type="url" required="required" placeholder="URL Here"> <input type="submit" value="Go"></form>这是使用输入url的 python 代码:@web_site.route('/home/ViewWindow/ViewWindowResult/', methods=('GET', 'POST'))def ViewWindowResult(): urlboi = request.values.get('url') response = urllibrequest.urlopen(url) # import urllib.request as urllibrequest htmlBytes = response.read() htmlstr = htmlBytes.decode("utf8") return html("ViewWindowResult.html", value=htmlstr)我的目标是到达这里;/home/ViewWindow/ViewWindow/ViewWindowResult/,但是当我输入“ https://www.w3schools.com/tags/”时, 我最终到达了这里;/home/ViewWindow/ViewWindowResult/?url=https%3A%2F%2Fwww.w3schools.com%2Ftags%2F为什么 Flask 将我的输入放在 url 字符串中?我不打算在任何地方这样做。编辑:您可以通过访问https://sm--supermechm500.repl.co/home/ViewWindow/来查看
2 回答
明月笑刀无情
TA贡献1828条经验 获得超4个赞
尝试像这样指定表单方法:
<form name="ViewWindow" action="/home/ViewWindow/ViewWindowResult/" method="post">
<input name="url" type="url" required="required" placeholder="URL Here">
<input type="submit" value="Go">
</form>
慕斯王
TA贡献1864条经验 获得超2个赞
使用 post 方法,如
<form name="ViewWindow" action="/home/ViewWindow/ViewWindowResult/" method="post">
<input name="url" type="url" required="required" placeholder="URL Here">
<input type="submit" value="Go">
</form
然后你的python代码是
@web_site.route('/home/ViewWindow/ViewWindowResult/', methods=('GET', 'POST'))
def ViewWindowResult():
input=request.form['url']
#write your code here
return(input)
它对我有用,它将打印您输入的相同网址
添加回答
举报
0/150
提交
取消