一个支持cors跨域的python最简simplehttpserver

测试时需要,

就随便找了找。。

from SimpleHTTPServer import SimpleHTTPRequestHandler
import BaseHTTPServer
 
class CORSRequestHandler (SimpleHTTPRequestHandler):
    def end_headers (self):
        self.send_header('Access-Control-Allow-Origin', '*')
        SimpleHTTPRequestHandler.end_headers(self)
 
if __name__ == '__main__':
    BaseHTTPServer.test(CORSRequestHandler, BaseHTTPServer.HTTPServer)

 

上一篇:python -m SimpleHTTPServer


下一篇:Python SimpleHTTPServer 转载:https://www.cnblogs.com/nopnog/p/8116848.html