flask基础操作
CSS层叠样式显示
- 在views中
@blue.route('/index/')
def index():
# 方法一
return send_file('../templates/hello.html')
# 方法二
# return render_template('hello.html')
- 在init.py中
def create_app():
# 方法一
app = Flask(__name__)
# 方法二
# BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# templates_dir = os.path.join(BASE_DIR, 'templates')
# start = os.path.join(BASE_DIR, 'static')
# app = Flask(__name__, template_folder=templates_dir, static_folder=start)
# 路由注册
app.register_blueprint(blueprint=blue)
return app
- 在hello.html中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>欢迎</title>
<link rel="stylesheet" href="/static/css/hello.css">
</