A small Python webserver for serving AMP files locally in development. Adds the required headers for CORS requests.
Run the server.py
script from the directory you wish to act as the root of your webserver:
$ python server.py
A small Python webserver for serving AMP files locally in development. Adds the required headers for CORS requests.
Run the server.py
script from the directory you wish to act as the root of your webserver:
$ python server.py
#!/usr/bin/env python | |
import SimpleHTTPServer | |
class AMPHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def end_headers(self): | |
self.send_my_headers() | |
SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self) | |
def send_my_headers(self): | |
self.send_header("Access-Control-Allow-Origin", "http://localhost:8000") | |
self.send_header("AMP-Access-Control-Allow-Source-Origin", "http://localhost:8000") | |
self.send_header("Access-Control-Expose-Headers", "AMP-Access-Control-Allow-Source-Origin") | |
if __name__ == '__main__': | |
SimpleHTTPServer.test(HandlerClass=AMPHandler) |