python拥有这种单独起一个服务器监听端口的能力,用标准库的wsgiref就行。
from wsgiref.simple_server import make_server
def simple_app(environ, start_response):
status = '200 OK'
response_headers = [('Content-type','text/plain')]
start_response(status, response_headers)
return ['Hello world!\n']
httpd = make_server('', 80, simple_app)
httpd.serve_forever()