Github地址: day0
初始化数据库:
jakeychen@JC:~/Public/tornado_todo$ pwd /home/jakeychen/Public/tornado_todo jakeychen@JC:~/Public/tornado_todo$ mysql -u root -p < todo.sql
输入密码 Aa123456 (假设你设置的密码为这个),完成mysql的初始化。
运行程序:
jakeychen@JC:~/Public/tornado_todo$ python srv.py
在浏览器(Chrome)查看运行效果:
尝试新增几个todo看一下效果:
标记为完成:
这样一个简单的待办事项就运行起来了
目前的项目大致结构:
tornado_todo/ ├── application.py ├── conf │ ├── config.yaml │ └── logging.yaml ├── handlers │ ├── base.py │ ├── delete.py │ ├── edit.py │ ├── finish.py │ ├── index.py │ ├── __init__.py │ └── new.py ├── logs │ ├── all.log │ ├── ingenia.log │ └── warn.log ├── README.md ├── srv.py ├── static │ ├── css │ │ ├── app.css │ │ └── normalize.css │ ├── images │ │ ├── favicon.ico │ │ ├── ok.gif │ │ └── tornado.png │ └── js ├── templates │ ├── base.html │ ├── edit.html │ └── index.html ├── todo.sql └── url.py
1. application.py 一些配置设置
1 # coding:utf-8 2 3 import os 4 import uuid 5 import base64 6 7 import tornado.web 8 9 settings = dict( 10 template_path=os.path.join(os.path.dirname(__file__), "templates"), 11 static_path=os.path.join(os.path.dirname(__file__), "static"), 12 xsrf_cookies=True, 13 cookie_secret=base64.b64encode(uuid.uuid4().bytes+uuid.uuid4().bytes), 14 login_url="/login", 15 debug=True, 16 )