使用 python -m SimpleHTTPServer 快速搭建http服务 测试真实访问IP地址

Posted 阿里云的奥斯卡

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用 python -m SimpleHTTPServer 快速搭建http服务 测试真实访问IP地址相关的知识,希望对你有一定的参考价值。

Python命令: python -m SimpleHTTPServer 8000

Python代码:

import SimpleHTTPServer
import SocketServer


class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def handle_one_request(self):
        print(self.client_address[0])
        return SimpleHTTPServer.SimpleHTTPRequestHandler.handle_one_request(self)

print("Serving local directory")
httpd = SocketServer.TCPServer(("", 8080), MyHandler)

while True:
    httpd.handle_request()

 

 可返回真实地址 测试web小工具

以上是关于使用 python -m SimpleHTTPServer 快速搭建http服务 测试真实访问IP地址的主要内容,如果未能解决你的问题,请参考以下文章