您的位置:首页 > 理论基础 > 计算机网络

python开启http服务

2018-09-17 14:14 429 查看
官方文档例子。

import http.server
import socketserver

port=8000
handl=http.server.SimpleHTTPRequestHandler

with socketserver.TCPServer(('127.0.0.1',port),handl) as httpd:
print('sering st port',port)
httpd.serve_forever()

直接用命令行也可以:

pyhon -m http.server 8000 --bind 127.0.0.1

如图,如果里面有index.html,会直接显示index.html页面

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: