-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpleproxy.py
More file actions
67 lines (51 loc) · 1.55 KB
/
Copy pathsimpleproxy.py
File metadata and controls
67 lines (51 loc) · 1.55 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/python
import os;
import shutil;
import json;
import web;
#from collections import defaultdict;
#from config import *;
urls = (
"/(.*)", "ProxyController",
)
from QuaintEgg.lib.Util import GenericUtil;
from QuaintEgg.lib.WebPyCustomizations import QuaintEggApplication;
from QuaintEgg.lib.Proxy import Proxy;
from QuaintEgg.framework.controllers.ControllerUtil import *;
application = None;
options = None;
global proxyAddress;
proxyAddress = "";
if __name__ == "__main__":
p = QuaintEggApplication.getParser()
p.add_argument("-a", "--proxy", default="http://localhost:7000", help="Proxy address");
options = p.parse_args();
proxyAddress = options.proxy
if proxyAddress[-1]=="/":
proxyAddress = proxyAddress[:-1]
web.config.debug = False
app = QuaintEggApplication(urls, globals());
class ProxyController:
def GET(self, path):
#jsonHook();
proxy = Proxy("%s/%s" %(proxyAddress, path));
res, headers = proxy.response(web.input().items(), "get", web.ctx.env)
for k,v in headers.items():
web.header(k,v);
return res
def PUT(self, path):
#jsonHook();
proxy = Proxy("%s/%s" %(proxyAddress, path));
res, headers = proxy.response(web.input().items(), "put", web.ctx.env)
for k,v in headers.items():
web.header(k,v);
return res
def DELETE(self, path):
#jsonHook();
proxy = Proxy("%s/%s" %(proxyAddress, path));
res, headers = proxy.response(web.input().items(), "delete", web.ctx.env)
for k,v in headers.items():
web.header(k,v);
return res
if __name__=="__main__":
app.run(port=options.port, host=options.host);