forked from phith0n/python-xss-filter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (38 loc) · 1.18 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
#coding=utf-8
__author__ = 'Phtih0n'
import web, os, pxfilter
urls = (
'.*', 'router'
)
class su:
def other(self):
raise web.seeother('main')
class router(su):
def __init__(self):
self.tplData = {}
self.globalsTplFuncs = {}
web.header("X-XSS-Protection", "0")
def GET(self):
self.assign("html", "")
return self.display("xsshtml")
def POST(self):
html = web.input(xsscode = "").xsscode
parser = pxfilter.XssHtml()
parser.feed(html)
parser.close()
html = parser.getHtml()
self.assign("html", html)
return self.display("xsshtml")
def assign(self,key,value = ''):
if type(key) == dict:
self.tplData = dict(self.tplData, **key)
else:
self.tplData[key] = value
def display(self, tplName):
self.tplData['render'] = web.template.render('html', globals = self.globalsTplFuncs)
return getattr(self.tplData['render'], tplName)(self.tplData)
if __name__ == '__main__':
app = web.application(urls, globals())
web.config.debug = True
app.run()