Skip to content

Commit cac4c1c

Browse files
Add Flask-Collect on manage
1 parent d483747 commit cac4c1c

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,6 @@ ENV/
9191

9292
# Database
9393
*.sqlite3
94+
95+
# Ignore collected static files
96+
static

manage.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
from flask_script import Manager
2+
from flask_collect import Collect
3+
24
from tvseries import create_app
35
from tvseries.config import DevelopmentConfig
46

57
app = create_app(config=DevelopmentConfig)
68
manager = Manager(app)
79

10+
collect = Collect()
11+
collect.init_app(app)
12+
13+
14+
@manager.command
15+
def collect():
16+
"""Collect static from blueprints."""
17+
return app.extensions['collect'].collect()
18+
819
if __name__ == "__main__":
920
manager.run()

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ Flask-SQLAlchemy==2.1
44
pytest-flask==0.10.0
55
python-decouple==3.0
66
uWSGI==2.0.14
7+
Flask-Collect==1.3.2

tvseries/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
import os
12
from decouple import config
23

34

45
class BaseConfig(object):
6+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
57
SITE_NAME = 'Flask Tutorial'
68
SECRET_KEY = config('SECRET_KEY')
79
SERVER_NAME = config('SERVER_NAME')
810
SQLALCHEMY_DATABASE_URI = config('DATABASE_URI')
911
SQLALCHEMY_TRACK_MODIFICATIONS = True
12+
COLLECT_STATIC_ROOT = os.path.join(BASE_DIR, "static")
13+
COLLECT_STORAGE = 'flask_collect.storage.file'
1014
DEBUG = False
1115
TESTING = False
1216

0 commit comments

Comments
 (0)