python 创建http.server服务器
快速的建立一个http server 服务器
1、将python环境变量设置好,path。。。
2、dos窗口中转到自己想要分享的文件夹下
3、输入python -m http.server 10086 即可
4、浏览器中查看127.0.0.1:10086即可看到
以下代码是在python3正常
#! /usr/bin/env python37
# -*- coding:utf-8 -*-
import configparser
import os
try:
import thread
except ImportError:
import _thread as thread
cf = configparser.ConfigParser()
cf.read(r'httpserer.ini')
#print cf.sections()
def start_file_server():
file_path = cf.get('FilePath','path')
print (file_path)
pan = (file_path.split(':')[0]).lower()
cmd = "{}: && cd {} && python -m http.server 10086".format(pan,file_path)
print (cmd)
os.system(cmd)
#logger.info('http server running on 8089 ')
def main_run():
thread.start_new_thread(start_file_server,())
#start_file_server()
if __name__ == "__main__":
main_run()
[FilePath]
path = E:\workspace\7-MySoftTool\
还没有评论,来说两句吧...