-
Notifications
You must be signed in to change notification settings - Fork 5
/
manage.py
47 lines (32 loc) · 1.32 KB
/
manage.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
from flask import Flask, render_template
from app.exts import db, mako
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from flask_redis import FlaskRedis
app = Flask(__name__, static_url_path='')
app.debug = True
# app.config["SQLALCHEMY_DATABASE_URI"] = "mysql+pymysql://root:[email protected]:3306/movie"
import os
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///{}".format(os.path.join(os.path.dirname(__file__), 'movie.sqlite'))
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
app.config["REDIS_URL"] = "redis://localhost:6379/0"
app.config["SECRET_KEY"] = os.urandom(24)
app.config["UP_DIR"] = os.path.join(os.path.abspath(os.path.dirname(__file__)), "static/uploads/")
app.config["FC_DIR"] = os.path.join(os.path.abspath(os.path.dirname(__file__)), "static/uploads/users/")
rd = FlaskRedis(app)
mako.init_app(app)
db.init_app(app)
manage = Manager(app)
migrate = Migrate(app, db)
manage.add_command('db', MigrateCommand)
from app.home import home as home_blueprint
from app.admin import admin as admin_blueprint
app.register_blueprint(home_blueprint)
app.register_blueprint(admin_blueprint, url_prefix="/admin")
# 404页面
@app.errorhandler(404)
def page_not_found(error):
return render_template("home/404.html"), 404
if __name__ == '__main__':
manage.run()