-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
33 lines (23 loc) · 927 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
from flask_bootstrap import Bootstrap
from flask_login import LoginManager
from flask_sqlalchemy import SQLAlchemy
from flask import Flask
basedir = os.path.abspath(os.path.dirname(__file__))
app = Flask(__name__)
app.config['SECRET_KEY'] = 'hard to guess'
# http://docs.sqlalchemy.org/en/latest/dialects/mysql.html
#数据库配置相关
#连接mysql数据库
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:123456@127.0.0.1:3306/flask_blog'
#连接sqlite数据库
# app.config['SQLALCHEMY_DATABASE_URI '] = 'sqlite:///' + os.path.join(basedir,
# 'data.sqlite')
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
bootstrap = Bootstrap(app)
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.session_protection = 'strong'
app.debug = True