-
Flask basic commandsDevelopment 2021. 7. 27. 15:45728x90
If there is app.py (Flask app), we can run it simply like below.
python3 app.py However, it is recommended to use Flask own environmental variable to run Flask app, please see below.
export FLASK_APP=app 🠔 Flask app name, it means 'app.py'
export FLASK_ENV=development 🠔 We run as developement purpose, otherwise production
export PORT=9010 🠔 Port number to use, normally, 80 port is already taken by running production service
flask run
flask run --reload 🠔 As *.py files are updated, flask reload *.py automatically as it detect any updated .py files.Be carefull, PORT is not default Flask environmental variable, however, please see how to use it below.
if __name__ == '__main__':
port = os.getenv('PORT', default=9050)
application.run(host='0.0.0.0', port=port)Lastly, your Flaks app is ready to launch, we should use gunicorn.
$ gunicorn -w 4 app:application 🠔 app means app.py, and application is declared in app.py 728x90'Development' 카테고리의 다른 글
Ubuntu에 Bugzilla설치하는 방법 (0) 2021.08.03 Postmortem, Udacity Full Stack Web Developer Nanodegree Program (0) 2021.07.27 My tweaks after installing Ubuntu (0) 2021.07.26 초보자용 리눅스 커맨드 학습 추천 (0) 2020.12.02 누구나 원하는 개발자되기 (0) 2020.11.30