【发布时间】:2020-07-17 18:48:01
【问题描述】:
我正在使用 Tornado (python),我的处理程序采用这种格式。
class Application(tornado.web.Application):
def __init__(self):
handlers = [
url(r'/', MainHandler, name="main_handler"),
url(r'/user', UserHandler, name="user_handler"),
url(r'/users', UserListHandler, name="user_list_handler"),
url(r'/profile/(?P<username>\w+)', UserProfileHandler, name="user_profile_handler"),
]
settings = dict(
template_path = os.path.join(os.path.dirname(__file__), "templates"),
static_path = os.path.join(os.path.dirname(__file__),"static"),
debug = True)
self.db = client['user_db']
super().__init__(handlers, **settings)
我在着陆页上的 HTML 代码是
<h1>INFO DB</h1>
<p>Search via username...</p>
<form method="get" action="{% url 'user_profile_handler' find_username %}">
<p>Enter Username<br>
<input rows=1 cols=20 name="find_username"></p>
<input type="submit">
</form>
<br>
现在我的目标是当我点击提交按钮时, 我被重定向到页面'/profile/{username} 例如:如果搜索栏中的用户名是“abcd”,我应该在按下提交时重定向到 /profile/abcd。 HTML中form标签的action属性要放什么?
【问题讨论】:
标签: python html django web tornado