-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhttp.py
executable file
·26 lines (21 loc) · 1.12 KB
/
http.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /usr/bin/env python
from SimpleHTTPServer import SimpleHTTPRequestHandler
import BaseHTTPServer
import os
class CORSRequestHandler (SimpleHTTPRequestHandler):
def end_headers (self):
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Access-Control-Allow-Methods', 'GET')
self.send_header('Access-Control-Allow-Headers', '*')
self.send_header('Access-Control-Allow-Headers', 'Pragma,Cache-Control,If-Modified-Since,Content-Type,X-Requested-With,X-stream,X-Ajax-Browser-Auth')
SimpleHTTPRequestHandler.end_headers(self)
def do_OPTIONS(self):
self.send_response(200)
# self.send_header('Access-Control-Allow-Origin', '*')
# self.send_header('Access-Control-Allow-Methods', 'GET, OPTIONS')
# self.send_header("Access-Control-Allow-Headers", "X-Requested-With")
# self.send_header("Access-Control-Allow-Headers", "Content-Type")
self.end_headers()
if __name__ == '__main__':
BaseHTTPServer.HTTPServer(("0.0.0.0", 8001), CORSRequestHandler).serve_forever()
# BaseHTTPServer.test(CORSRequestHandler, BaseHTTPServer.HTTPServer)