I end up running server at root "/"
with python -m SimpleHTTPServer 8888 &
accessing my html file from localhost
for e.g. - http://localhost:8888/home/meet/workspace/d3_test/scripts/data_fetch.html
and my tsv file is on following location
http://localhost:8888/home/meet/data/data.tsv
Note:- Setting up your SimpleHTTPServer at root "/"
helps you to fetch any file from any directory at given security cost.
EDIT:-
Unfortunately, SimpleHTTPServer is really that simple that it does not allow any customization, especially not of the headers it sends. You can however create a simple HTTP server yourself, using most of SimpleHTTPServer and just add that desired header.
Simply create a file simple-cors-http-server.py (or whatever) and put the following inside:
#! /usr/bin/env python2
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)
Then you can do python simple-cors-http-server.py and it will launch your modified server which will set the CORS header for every response.