forked from LLNL/DragonView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
33 lines (26 loc) · 859 Bytes
/
server.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
27
28
29
30
31
32
33
import os
from sys import argv
try:
from SimpleHTTPServer import SimpleHTTPRequestHandler as Handler
from SocketServer import TCPServer as Server
except ImportError:
from http.server import SimpleHTTPRequestHandler as Handler
from http.server import HTTPServer as Server
PORT = int(os.getenv('DRAGONVIEW_PORT', 8000))
DATA_DIR = 'sim'
if len(argv) == 2:
DATA_DIR = argv[1]
#if DATA_DIR[-1:] != '/':
# DATA_DIR += '/'
DATA_DIR = '/data/'+DATA_DIR
class MyHandler(Handler):
def do_GET(self):
print 'PATH: ', self.path[:5]
if self.path[:5] == '/data':
print 'path:', self.path
self.path = DATA_DIR + self.path[5:]
print 'new path:', self.path
Handler.do_GET(self)
httpd = Server(("", PORT), MyHandler)
print 'Port %i \nDATA %s' % (PORT, DATA_DIR)
httpd.serve_forever()