HTML基础(3.2 input)

继续,完善后台

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <form action="http://localhost:8888/index" method="get">
        <!-- method为提交方式,有get和post,先了解就好-->
        <input type="text" name="user" \>
        <input type="text" name="email" \>
        <input type="password" name="pwd" \>
        <input type="button" value="登录1" \>
        <!--在学习JS之前,默认BUTTON无用,只是摆设-->
        <input type="submit" value="登录2" \>
        <!-- 提交的是一个字典形式,详见Python基础-->
    </form>
</body>
</html>
import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        print(111)
        u = self.get_argument('user')
        e = self.get_argument('email')
        p = self.get_argument('pwd')
        if u=='yiqing' and p=='handsome' and e=='[email protected]':
            self.write("成功")
        else:
            self.write("错误")

    def post(self, *args, **kwargs):
        print(123)
        self.write("POST")

application = tornado.web.Application([
    (r"/index", MainHandler),
])
if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
打开网页登录

HTML基础(3.2 input)

输入正确后

HTML基础(3.2 input)

可以发现,以GET方式提交的信息全部拼接到URL上

如果改成POST形式


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <form action="http://localhost:8888/index" method="post">
        <!-- method为提交方式,有get和post,先了解就好-->
        <input type="text" name="user" \>
        <input type="text" name="email" \>
        <input type="password" name="pwd" \>
        <input type="button" value="登录1" \>
        <!--在学习JS之前,默认BUTTON无用,只是摆设-->
        <input type="submit" value="登录2" \>
        <!-- 提交的是一个字典形式,详见Python基础-->
    </form>
</body>
</html>
HTML基础(3.2 input)

post提交没有放在URL上

不过,不要认为POST提交就是安全的,因为抓包工具都可以抓到,我会专门开一类讲解抓包工具