Created
August 28, 2012 13:41
-
-
Save cjgiridhar/3498074 to your computer and use it in GitHub Desktop.
Tornado - Options - 2
This file contains 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
from tornado.options import options,define | |
define("host", default="localhost", help="DB host") | |
define("database", default="mydb", help="DB used") | |
define("user", default="root", help="DB username") | |
define("password", default="root", help="DB Password") | |
define("port", default=8888) |
This file contains 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
from tornado.options import define, options | |
import tornado.web | |
import tornado.database | |
import opts | |
class DBHandler(tornado.web.RequestHandler): | |
def get(self): | |
db = tornado.database.Connection(options.host, options.database, options.user, options.password) | |
db.close() | |
application = tornado.web.Application([ | |
(r"/db", DBHandler), | |
], debug=True) | |
if __name__ == '__main__': | |
application.listen(options.port) | |
tornado.ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment