[1] Tornado Todo Day0, tornadotododay0
Github address: day0
Initialize the database:
jakeychen@JC:~/Public/tornado_todo$ pwd/home/jakeychen/Public/tornado_todojakeychen@JC:~/Public/tornado_todo$ mysql -u root -p < todo.sql
Enter the password Aa123456 (assuming the password you set is this) to complete mysql initialization.
Run the program:
jakeychen@JC:~/Public/tornado_todo$ python srv.py
View the Running Effect in the browser (Chrome:
Try to add several todo items to check the effect:
Mark as complete:
Such a simple to-do task will run.
The general structure of the current project:
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 configuration settings
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)View Code
2. url. py record URL and ing Class
1 # coding: UTF-8 2 3 4 url = [(r "^/", "handlers. index. indexHandler ")] 5 6 url + = [(r" ^/todo/new "," handlers. new. newHandler ")] 7 8 url + = [(r" ^/todo/(\ d +)/edit "," handlers. edit. editHandler ")] 9 10 url + = [(r" ^/todo/(\ d +)/delete "," handlers. delete. deleteHandler ")] 11 12 url + = [(r" ^/todo/(\ d +)/finish "," handlers. finish. finishHandler ")]View Code
3. todo. SQL initializes mysql
1 # $ mysql-u root-p <mysql_create. SQL 2 # Aa123456 3 4 drop database if exists tornado_todo; 5 6 create database tornado_todo; 7 8 GRANT ALL ON tornado_todo. * TO 'tornado 'identified BY '123456'; 9 10 use tornado_todo; 11 12 create table todo (13 'id' mediumint not null auto_increment, 14 'todo _ text' varchar (50) not null, 15 'finished' bool not null default 0, 16 'Post _ date' datetime not null default now (), 17 primary key ('id') 18) engine = innodb default charset = utf8;View Code
4. handlers/request classes
5. static/static files
6. templates/html file
7. conf/configuration file
8. logs/store log files
Todo:
1. Use jquery to separate all css and js.
2. Use sqlalchemy to rewrite the database.