-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
29 lines (26 loc) · 855 Bytes
/
config.py
File metadata and controls
29 lines (26 loc) · 855 Bytes
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
import yaml
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_session import Session
from flask_migrate import Migrate
with open('database.yaml', 'r') as file:
config = yaml.safe_load(file)
class Config:
SESSION_TYPE = 'filesystem'
SECRET_KEY = 'your_secret_key'
SQLALCHEMY_DATABASE_URI = (f"postgresql://{config['database']['user']}:{config['database']['password']}"
f"@{config['database']['host']}:{config['database']['port']}/{config['database']['dbname']}")
app = Flask(__name__)
app.config.from_object(Config)
Session(app)
db = SQLAlchemy(app)
migrate = Migrate(app, db)
student_categorys={
11:'本科生',
13:'本科交换生',
18:'本科留学生',
31:'学术研究生',
32:'专业研究生',
33:'研究生交换生',
38:'研究生留学生',
}