This is an experimental web project when I'm learning flask by a flask book wrote by Miguel Grinberg.
The main functions of this project is to draw diagrams on web:
- Flow chart
- Mindmap
- UML diagram: class diagram, sequence diagram, state diagram, etc.
There are two methods to generate diagram
- Web gui
- Command line
write a script as below
NIO -> Channel
NIO -> Buffer
NIO -> Selector
Buffer -> ByteBuffer
Buffer -> CharBuffer
Buffer -> MappedByteBuffer
Channel -> FileChannel
Channel -> DatagramChannel
Channel -> SocketChannel
Channel -> ServerSocketChannel
then generate the following diagram
- Login flow chart
write a script as below
start -> IsExceedMaxAttempts
IsExceedMaxAttempts -> Login[cond=no]
IsExceedMaxAttempts -> LockAccount[cond=yes]
LockAccount -> DisplayAlert
Login -> IsAuthorized
IsAuthorized -> GrantAccess[cond="yes"]
IsAuthorized -> IsExceedMaxAttempts[cond="no"]
GrantAccess -> end
DisplayAlert -> end
fab draw:./examples/login-flowchart.txt,./examples/login-flowchart.png
then generate the following chart
- tcp handshake
write a script as below
title TCP handshake
participant client
participant server
autonumber "<b>[00]"
== open ==
note right of server: LISTEN
client -> server: SYN
note left of client: SYN_SENT
note right of server: SYN_RCVD
server --> client: ACK/SYN
server -> client: ACK
note over client, server: ESTABILISHED
== close ==
client -> server: FIN
note left of client: FIN_WAIT_1
note right of server: CLOSE_WAIT
server --> client: ACK
note left of client: FIN_WAIT_2
server -> client: FIN
note right of server: LAST_ACK
note left of client: TIME_WAIT
client --> server: ACK
note right of server #FFAAAA: CLOSED
then generate the following diagram
[*] --> Created: new
Created --> Ready: start
Ready --> Running: run
Running --> Ready: yield, interrupt
Running --> Waiting: wait, sleep, suspend
Waiting --> Ready: notify, resume
Running --> Terminated
Terminated --> [*]
brew install libev
brew install python3
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
source setenv.sh
# vi .env
FLASK_APP=app
MAIL_SERVER = smtp.163.com
MAIL_PORT = 465
MAIL_USE_SSL = true
MAIL_USE_TLS = false
MAIL_USERNAME = ***@163.com
MAIL_PASSWORD = ******
ADMIN_DEFAULT_EMAIL=***@163.com
ADMIN_DEFAULT_PASSWORD = ********
fab init_db
run server
open http://localhost:5000 and login with the default administrar account as above
source ./venv/bin/activate
export FLASK_DEBUG=1
export FLASK_APP=app.py
flask run --host=0.0.0.0 --port=8000 &
sqlite3 web-diagram-dev.db
sqlite> .schema
sqlite> .quit
flask test
flask shell
>>> user = User.query.all()