A simple ticket selling system project using flask, sqlalchemy, mysql, deployed with docker
Built and tested on
- docker 17.05.0-ce, build 89658be
- docker-compose version 1.8.0, build f3628c7
- Database Design: Design diagram
- API Documentation: API
- python3.5
- mysql5.7
- python modules
- flask==0.12
- sqlalchemy==1.1.10
- flask_sqlalchemy==2.2
- flask_hashing==1.1
- configparser==3.5.0
- pymysql==0.7.9
- mixer==5.6.6
- Goto project root directory, execute
sudo pip3 install -r requirements.txt
to install python modules - Modify configuration file in
src/config.d/config.conf
with your special needs - Ensure mysql database is set as in
config.conf
file - Goto
src/
and executepython3 server.py start
and you are all set
- docker
- docker-compose
- Goto
docker/
- Put
.env
file in it. The contents are documented later - Execute
docker-compose up -d
and you are all set
Do not modify src/config.d/config.conf
when you deploy to docker
TICKET_SERVER_CMD
start
Run servertest
Run test and exit
TICKET_SERVER_PORT
9999
Deloying port
Flask session is based on cookies, and you must set a secret key to it so that the cookies are encrypted and cannot be read by others
The secret key is set in src/app/__init__.py
and is not configurable in config.conf
file. It is recommanded to use a random string as secret key, just as documented in Flask quick start
Python module mixer
is a fake data generator. To auto-generate data and store them into database, you can start the server with test parameter (pass test
as parameter when run in host, or set TICKET_SERVER_PORT=test
in .env file when run in docker)
Problem is that it cannot deal with FK in a good manner, so to create tickets, you must insert to database on your own.
More usage is documented in here
Passwords are hashed and not salted before they are stored into database. To have customed pasword hashing, reference flask_hashing
- Seperate routers and handlers
- Some basic operation can be encapsulated into models
- Log system
- Distributed system, with nginx as proxy server
- Database cluster and data backup
- Cache movie and cinema infomation in Redis
...