-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathproxy.py
51 lines (36 loc) · 1.16 KB
/
proxy.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!C:\\Python27\\python.exe
"""
Copy html2canvasproxy.py to this folder
Replace `#!C:\\Python27\\python.exe`
"""
from html2canvasproxy import *
import os
import cgi
import cgitb; cgitb.enable()
form = cgi.FieldStorage()
url = form.getvalue('url')
callback = form.getvalue('callback')
debug_vars = form.getvalue('debug_vars')
real_path = os.path.dirname(os.path.realpath(__file__)) + '\\images'
virtual_path = 'cgi-bin/html2canvas/images'
h2c = html2canvasproxy(callback, url)
#h2c.enable_crossdomain() #Uncomment this line to enable the use of "Data URI scheme"
if 'HTTP_HOST' in os.environ:
host = 'http://' + os.environ['HTTP_HOST']
else:
host = 'http://localhost' #alternative HOST, define your domain eg. http://mywebsite.io
h2c.hostname(host)
if 'HTTP_REFERER' in os.environ:
h2c.referer(os.environ['HTTP_REFERER'])
if 'HTTP_USER_AGENT' in os.environ:
user_agent = os.environ['HTTP_USER_AGENT']
else:
h2c.useragent('Mozilla/5.0')
h2c.route(real_path, virtual_path)
if debug_vars:
print 'Content-Type: text/plain\r\n'
print h2c.debug_vars()
else:
r = h2c.result()
print 'Content-Type: ' + r['mime'] + '\r\n'
print r['data']