Last active
December 27, 2015 08:49
-
-
Save maliubiao/7299530 to your computer and use it in GitHub Desktop.
tornado-trace.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title> | |
| trace enabled | |
| </title> | |
| </head> | |
| <body> | |
| <p> trace enabled </p> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title> | |
| trace disabled | |
| </title> | |
| </head> | |
| <body> | |
| <p> trace disabled </p> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| import stacktrace | |
| stacktrace.starttrace("tornado.stacks") | |
| import os.path | |
| import re | |
| import tornado.auth | |
| import tornado.httpserver | |
| import tornado.ioloop | |
| import tornado.options | |
| import tornado.web | |
| import unicodedata | |
| from tornado.options import define, options | |
| define("port", default=8888, help="run on the given port", type=int) | |
| define("mysql_host", default="127.0.0.1:3306", help="blog database host") | |
| define("mysql_database", default="tornado", help="blog database name") | |
| define("mysql_user", default="root", help="blog database user") | |
| define("mysql_password", default="#########", help="blog database password") | |
| class Application(tornado.web.Application): | |
| def __init__(self): | |
| handles = [ | |
| (r"/", HomeHandler), | |
| (r"/st", TraceHandler) | |
| ] | |
| settings = dict( | |
| title = "tornado trace", | |
| 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= "THIS IS A RANDOM VALUE", | |
| debug = True | |
| ) | |
| tornado.web.Application.__init__(self, handles, **settings) | |
| class HomeHandler(tornado.web.RequestHandler): | |
| def get(self): | |
| self.render("home.html", entries=None) | |
| class TraceHandler(tornado.web.RequestHandler): | |
| def get(self): | |
| stacktrace.stoptrace() | |
| self.render("stop.html", entries=None) | |
| def main(): | |
| tornado.options.parse_command_line() | |
| http_server = tornado.httpserver.HTTPServer(Application()) | |
| http_server.listen(options.port) | |
| tornado.ioloop.IOLoop.instance().start() | |
| if __name__ == "__main__": | |
| main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment