aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/web/app.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2014-11-28 19:16:47 +0100
committerMaximilian Hils <git@maximilianhils.com>2014-11-28 19:16:47 +0100
commitc39b6e4277357c9da1dfd5e3e8c41b5b3427e0ce (patch)
tree21a713fb0974242dc0cf7023eac1dfda7865419c /libmproxy/web/app.py
parent7ca1ac0f3b7856c0ae44bfbf3b27ae4a424a1cc2 (diff)
downloadmitmproxy-c39b6e4277357c9da1dfd5e3e8c41b5b3427e0ce.tar.gz
mitmproxy-c39b6e4277357c9da1dfd5e3e8c41b5b3427e0ce.tar.bz2
mitmproxy-c39b6e4277357c9da1dfd5e3e8c41b5b3427e0ce.zip
web: various fixes, add clear button
Diffstat (limited to 'libmproxy/web/app.py')
-rw-r--r--libmproxy/web/app.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/libmproxy/web/app.py b/libmproxy/web/app.py
index 4fdff783..05ca7e79 100644
--- a/libmproxy/web/app.py
+++ b/libmproxy/web/app.py
@@ -1,4 +1,5 @@
import os.path
+import sys
import tornado.web
import tornado.websocket
import logging
@@ -8,6 +9,7 @@ from .. import flow
class IndexHandler(tornado.web.RequestHandler):
def get(self):
+ _ = self.xsrf_token # https://github.com/tornadoweb/tornado/issues/645
self.render("index.html")
@@ -35,13 +37,18 @@ class WebSocketEventBroadcaster(tornado.websocket.WebSocketHandler):
logging.error("Error sending message", exc_info=True)
-class FlowsHandler(tornado.web.RequestHandler):
+class Flows(tornado.web.RequestHandler):
def get(self):
self.write(dict(
flows=[f.get_state(short=True) for f in self.application.state.flows]
))
+class FlowClear(tornado.web.RequestHandler):
+ def post(self):
+ self.application.state.clear()
+
+
class FlowUpdates(WebSocketEventBroadcaster):
connections = set()
@@ -56,14 +63,15 @@ class Application(tornado.web.Application):
handlers = [
(r"/", IndexHandler),
(r"/updates", ClientConnection),
- (r"/flows", FlowsHandler),
+ (r"/flows", Flows),
+ (r"/flows/clear", FlowClear),
(r"/flows/updates", FlowUpdates),
]
settings = dict(
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"),
xsrf_cookies=True,
- cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
+ cookie_secret=os.urandom(256),
debug=debug,
)
tornado.web.Application.__init__(self, handlers, **settings)