4

Flask

 3 years ago
source link: https://feiyang233.club/post/flask/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

费洋的博客

Flask

2020-04-25

|

2020-09-22

| develop

| 2 Comments

|

For develop some internal tools.

reference docs

pyvenv

Recommend to use pyvenv to develop flask, easy to manage the python version and packages

1
2
3
python3 -m venv /path/to/new/virtual/environment

source /path/to/new/virtual/environment

install flask

1
2
3
4
5
6
7
8
# under virtual env
pip install Flask

pip install flask-appbuilder

flask fab create-app

flask run

SQLAlchemy

Sometimes, if it’s not easy to add constriant condition on model.py in database level, we can try from application level by built-in methods pre_add https://flask-appbuilder.readthedocs.io/en/latest/api.html#flask_appbuilder.baseviews.BaseCRUDView.pre_add

security

Put sensitive data in file .env

1
SECRET_KEY=secret key

Use os module method getenv()
1
2
3
import os

secret_key = os.getenv("SECRET_KEY","default value")

issue

© 2018 – 2020 feiyang

Powered by Hexo v4.2.0

|

Theme – NexT.Gemini v7.0.1

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK