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 

[1] Tornado Todo Day0

在浏览器(Chrome)查看运行效果:

[1] Tornado Todo Day0

尝试新增几个todo看一下效果:

[1] Tornado Todo Day0

标记为完成:

[1] Tornado Todo Day0

这样一个简单的待办事项就运行起来了

 

目前的项目大致结构:

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 )
View Code

相关文章:

  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2021-06-24
  • 2022-01-25
  • 2021-04-19
  • 2022-01-17
猜你喜欢
  • 2022-12-23
  • 2021-04-26
  • 2022-12-23
  • 2021-05-18
  • 2021-06-13
  • 2021-10-17
  • 2022-01-13
相关资源
相似解决方案