• 14-2


    块级标签: div(白板)

    标签之间可以嵌套

    为什么要有标签?
    标签存在的意义: 定位操作, css操作, js操作

    chrome审查元素的使用
    - 定位
    - 查看样式

    用id定位

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <p id="p1">hello world</p>
    <div id="i1">qwert</div>
    
    </body>
    </html>
    
    打开页面->Inspect->Console, 
    document.getElementById('i1').innerText
    "qwert"
    document.getElementById('i1').innerText="asdfg"
    "asdfg"

    定义位置: 右上角

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <p id="p1">hello world</p>
    <div id="i1" style="position: fixed;top: 0;right: 0;">qwert</div>
    
    </body>
    </html>

    定义位置: 右下角

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <p id="p1">hello world</p>
    <div id="i1" style="position: fixed;bottom: 0;right: 0;">qwert</div>
    
    </body>
    </html>

    提交表单

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <form action="http://localhost:8888/index">
            <input type="text" />
            <input type="password" />
            <input type="button" value="登录1" />
            <input type="submit" value="登录2" />
        </form>
    </body>
    </html>
    #pip3 install tornado
    
    import tornado.ioloop
    import tornado.web
    
    class MainHandler(tornado.web.RequestHandler):
        def get(self):
            print(111)
            self.write('GET')
        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()

    浏览器打开http://localhost:8888/index会返回get方法
    浏览器post到http://localhost:8888/index会返回post方法

    浏览器打开html页面,输入内容,点击登录2,数据就提交给http://localhost:8888/index

    获取表单内容

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <form action="http://localhost:8080/index">
            <input type="text" name="user" />
            <input type="text" name="email" />
            <input type="password" name="pwd" />
            <input type="button" value="登录1" />
            <input type="submit" value="登录2" />
        </form>
    </body>
    </html>

    用户输入会打包成字典提交到后台
    {'user':'输入的用户', 'email':'xx', 'pwd':'xx'}

    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 == 'alex' and e == 'alex@126.com' and p == '123':
                self.write("OK")
            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(8080)
        tornado.ioloop.IOLoop.instance().start()

    POST方法提交表单数据

    GET, POST
    GET提交在URL里
    POST提交在body里, URL里看不到

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <form action="http://localhost:8080/index" method="POST">
            <input type="text" name="user" />
            <input type="text" name="email" />
            <input type="password" name="pwd" />
            <input type="button" value="登录1" />
            <input type="submit" value="登录2" />
        </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 == 'alex' and e == 'alex@126.com' and p == '123':
                self.write("OK")
            else:
                self.write("")
        def post(self, *args, **kwargs):
            u = self.get_argument('user')
            e = self.get_argument('email')
            p = self.get_argument('pwd')
            print(u, e, p)
            self.write('POST')
    application = tornado.web.Application([
        (r'/index', MainHandler),
    ])
    
    if __name__ == "__main__":
        application.listen(8080)
        tornado.ioloop.IOLoop.instance().start()

    浏览器打开html页面,输入内容,点击登录2,数据就提交给http://localhost:8080/index

  • 相关阅读:
    Logstash-input-jdbc同步mysql数据到ES - sql_last_value
    filebeat7.5.2 在 windows server 2008 R2 设置系统服务报错
    mysql8.0.19压缩版安装
    不是RESTful不好,是你姿势有问题
    logback运行时动态创建日志文件
    jpa 主键重复导致查询list的数据总是重复第一条数据
    解决MySQL Workbench导出低版本MySQL时报错Unknown table ‘column_statistics’ in information_schema的问题
    windows10系统修改JDK版本后配置环境变量不生效怎么办
    application.properties 中文乱码问题解决
    JAVA抽象类和抽象方法(abstract)
  • 原文地址:https://www.cnblogs.com/python-abc/p/11729935.html
Copyright © 2020-2023  润新知