-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·31 lines (23 loc) · 968 Bytes
/
main.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
#!/usr/bin/env python
import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.api import urlfetch
import cgi
import urllib
class PondProxyController(webapp.RequestHandler):
def get(self):
result = urlfetch.fetch(url=self.request.GET.get('url'), method=urlfetch.GET)
self.response.headers["Content-Type"] = "application/json"
self.response.out.write('{"status": { "http_code":' + str(result.status_code) + ' }, "contents": ' + result.content + '}')
class MainHandler(webapp.RequestHandler):
def get(self):
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(open(path, 'r').read())
def main():
application = webapp.WSGIApplication([('/', MainHandler),
('/proxy.php', PondProxyController)],
debug=True)
util.run_wsgi_app(application)
if __name__ == '__main__':
main()