File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 1
1
import BaseHTTPServer
2
2
import subprocess
3
+ import sys
3
4
4
5
MUNTA_PATH = "./munta"
5
6
PORT = 3069
6
7
8
+
7
9
def run_munta (query ):
8
- p = subprocess .Popen ([MUNTA_PATH ], stdin = subprocess .PIPE , stdout = subprocess .PIPE )
10
+ p = subprocess .Popen ([MUNTA_PATH , '-s' ],
11
+ stdin = subprocess .PIPE , stdout = subprocess .PIPE )
9
12
return p .communicate (input = query )
10
13
14
+
11
15
class handler (BaseHTTPServer .BaseHTTPRequestHandler ):
12
16
def _set_headers (self ):
13
17
self .send_response (200 )
@@ -25,9 +29,17 @@ def do_POST(self):
25
29
self ._set_headers ()
26
30
self .wfile .write (run_munta (post_data )[0 ])
27
31
32
+
28
33
def run (server_class = BaseHTTPServer .HTTPServer , handler_class = handler ):
29
34
server_address = ('' , PORT )
30
35
httpd = server_class (server_address , handler_class )
31
36
httpd .serve_forever ()
32
37
33
- run ()
38
+
39
+ if __name__ == "__main__" :
40
+ print ("Server started." )
41
+ try :
42
+ run ()
43
+ except KeyboardInterrupt :
44
+ print ("Server shutting down." )
45
+ sys .exit (0 )
You can’t perform that action at this time.
0 commit comments