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
import tornado.ioloop | |
import tornado.web | |
import urlparse | |
## mongodb and pymongo installation assumed | |
import pymongo | |
from pymongo import Connection | |
class Article(tornado.web.RequestHandler): | |
def initialize(self): |
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
import tornado.web | |
import tornado.autoreload | |
class Main(tornado.web.RequestHandler): | |
def get(self): | |
self.write('Main') | |
application = tornado.web.Application([ | |
(r"/", Main) | |
]) |
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
import tornado.web | |
import tornado.autoreload | |
class Main(tornado.web.RequestHandler): | |
def get(self): | |
self.write("Main") | |
application = tornado.web.Application([ | |
(r"/", Main) | |
]) |
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
port="8000" | |
host="localhost" | |
databse="mydb" | |
user="root" | |
password="root" |
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
from tornado.options import define, options | |
import tornado.web | |
import tornado.database | |
define("port", default="8888") | |
class DBHandler(tornado.web.RequestHandler): | |
def get(self): | |
self.write("Main") |
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
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 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
from tornado.options import define, options | |
import tornado.web | |
import tornado.database | |
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 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
import tornado.web | |
import tornado.escape | |
class Main(tornado.web.RequestHandler): | |
def get(self): | |
self.write("<br />") | |
self.write(tornado.escape.linkify("Linked URL: http://technobeans.com/2012/08/22/tornado-database-mysql-client-wrapper/")) | |
self.write("<br />") | |
self.write(tornado.escape.linkify("Short URL: http://technobeans.com/2012/08/22/tornado-database-mysql-client-wrapper/", shorten=True)) | |
self.write("<br />") |
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
import tornado.httpclient | |
http = tornado.httpclient.HTTPClient() | |
response = http.fetch("http://localhost:8888/lang") | |
data = tornado.escape.json_decode(response.body) | |
print data['py'], data['js'] |
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> | |
<title> | |
JSON Example | |
</title> | |
<body> | |
<FORM ACTION="/blog" METHOD=POST> | |
Title: <input type="text" name="title"> | |
Author: <input type="text" name="author"> |