一、html

1、web流程中的HTML

HTML---->赤裸裸的人

CSS  ---->穿华丽的衣服

JS    ---->让人动起来

浏览器和server端之间的通信本质上是字符串;浏览器将字符串处理为可视化的东西;

web框架的祖宗是socket;

#!/usr/bin/env python
# _*_ coding:utf-8 _*_
import socket
def handle_request(client):
    buf = client.recv(1024)
    client.send("HTTP /1.1 200 OK \r\n\r\n")
    client.send("<h1 style='color=red;'>123456</h1>")

def main():
    sock = socket.socket()
    sock.bind(('localhost',8004))
    sock.listen(5)
    while True:
        connection,address = sock.accept()
        handle_request(connection)
        connection.close()

if __name__ == '__main__':
    main()
View Code

相关文章: