flask会话笔记
def login():
......
#用多行html代码显示网页
return '''
<form action="" method="post">
<p><input type="text" name="username"/></p>
<p><input type="submit" value="登录"/></p>
</form>
'''
def index():
......
#用字符串显示网页,末尾用斜杠连接两段字符串
return "您暂未登录,<br><a href = '/login'><b>"+\
"点击这里登录</b></a>"
在返回值中写简短html代码可以将网页作为返回值展现给用户,上述两种格式分别用短字符串和多行html代码表示。
第一段中的html的表单action为空会跳转回login()函数进行处理。一般通过redirect,html链接等跳转时method为get,表单中明确标注"method=‘POST’"时才为POST。