Flask learning notes 1

Environment Set Up

1. install python and pip3

2. install virtual environment tool

pip3 install virtualenv

3. make a new directory and enter it to build the venv and activate it.

virtualenv --no-site-packages venv
source venv/bin/activate

4. install flask

source venv/bin/activate

5. write a python route script and set env variables

export FLASK_APP=flaskexample.py
# This will set flask to the main script to be run,
# so that we can use "flask run" to run the project
export FLASK_DEBUG=1
# This will allow us to refresh the web page without rerun the script

6. without set the env variables, we can also achieve 5 by running the python script with a main function in it.

if __name__ == '__main__':
    app.run(debug=True)

7. to present a user interface, we need forms. A Form’s elements such as text input, radio, select etc. can be used appropriately. Flask-WTF is an useful lib for doing this, and can also render the forms in many styles. To install this package just use the following command in the virtual environment you built.

pip install flask-WTF

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值