zoukankan      html  css  js  c++  java
  • html_py

    Sock.py

    import socket
    def handle_request(client):
        buf=client.recv(1024)
        client.send(bytes("HTTP/1.1 200 0k ",encoding="utf-8"))
        client.send(bytes("<h1 style=''>hello,eight<h1>",encoding="utf-8"))
    def main():
        sock_1=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
        sock_1.bind(('localhost',8010))
        sock_1.listen(5)

        while True:
            connection,address=sock_1.accept()
            handle_request(connection)
            connection.close()

    if __name__=="__main__":
        main()

    S2.py

    import socket
    def handle_request(client):
        buf=client.recv(1024)
        client.send(bytes("HTTP/1.1 200 0k ",encoding="utf-8"))
        f=open('index.html','r',encoding='utf-8')
        data=f.read()
        f.close()
        import time
        r1 = str(time.ctime())
        d=data.replace('time',r1)
        client.send(d.encode())
    def main():
        sock_1=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
        sock_1.bind(('localhost',8010))
        sock_1.listen(5)

        while True:
            connection,address=sock_1.accept()
            handle_request(connection)
            connection.close()

    if __name__=="__main__":
        main()

    App.py

    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('password')
            if u == 'jack' and p == '123456' and e == 'jack@126.com':
                self.write("OK")
            else:
                self.write("False")

        def post(self, *args, **kwargs):
            u = self.get_argument('user')
            e = self.get_argument('email')
            p = self.get_argument('password')
            print(u, e, p)
            print(123)
            self.write('post')


    application = tornado.web.Application([
        (r"/index", MainHandler),
    ])

    if __name__ == "__main__":
        application.listen(8888)
        tornado.ioloop.IOLoop.instance().start()
  • 相关阅读:
    ubuntu(14.4) 安装phpmyadmin
    ubuntu(14.04) 安装ssh,并使用root用户登录
    ubuntu(14.04版本) 配置虚拟环境(一个ip对应多个域名)
    ubuntu 中数据的迁移
    ubuntu修改固定ip
    作业调度框架_Quartz
    tomcat设置端口号和默认webapp
    HTTP深入浅出 http请求
    HTTP协议详解
    如何准备阿里社招面试,顺谈 Java 程序员学习中各阶段的建议【转】
  • 原文地址:https://www.cnblogs.com/leiwenbin627/p/10640869.html
Copyright © 2011-2022 走看看