Skip to content

Commit

Permalink
集成redis和csrfprotect
Browse files Browse the repository at this point in the history
  • Loading branch information
zhushixia committed Aug 16, 2018
1 parent 8535c69 commit 66c3da1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions manager.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.wtf import CSRFProtect
from redis import StrictRedis


class Config(object):#项目的配置
DEBUG = True
#为数据库添加配置
SQLAlchemy_DATABASE_URI = "mysql://root:[email protected]:3306/information27"
SQLALCHEMY_TRACK_MODIFICATIONS = False
#Redis的配置
REDIS_HOST = "127.0.0.1"
REDIS_PORT = 6379

app = Flask(__name__)
#加载配置
app.config.from_object(Config)

#初始化数据库
db = SQLAlchemy(app)
#初始化redis存储对象
redis_store = StrictRedis(host=Config.REDIS_HOST, port=Config.REDIS_PORT)
#开启当前项目csrf保护,只做服务验证工作
CSRFProtect(app)



@app.route("/")
Expand Down

0 comments on commit 66c3da1

Please sign in to comment.