TornaREST is a simple RESTful Web Service build with Tornado Web Server.It's a demo and a base framework for learning how to build a web service provides RESTful API.
How to use Python to build a RESTful Web Service
- Create
config.py
in the project root path:
DOMAIN = 'http://127.0.0.1'
DB_HOST = 'localhost'
DB_PORT = 27017
DB_NAME = 'test'
DB_USER = 'root'
DB_PWD = 'your password'
REDIS_HOST = 'localhost'
REDIS_PORT = 6379
AES_KEY = 'your aes key'
TOKEN_TIMEOUT = 60 * 60 * 24 * 30
QINIU_AK = ''
QINIU_SK = ''
QINIU_BUCKET_NAME = ''
QINIU_HOST = ''
- Run
util/init_db.py
- Run
server.py
{
'code': code,
'msg': msg,
'data': data
}
- Using tornado
- Using mongodb
- Using redis
- Using qiniu for image storage
- You can use apidoc to generate your api doc