File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed
Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 11FROM python:3.5
2- ADD . /code
32WORKDIR /code
4- RUN pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple && ./manage.py collectstatic --noinput
3+ ADD requirements.txt /code
4+ RUN pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
5+ ADD . /code
6+ RUN ./manage.py collectstatic --noinput
57CMD ./run_uwsgi.sh 8000
Original file line number Diff line number Diff line change 1+ from django .conf import settings
2+
3+
4+ class AddLinkHeaderMiddleware (object ):
5+ def process_response (self , request , response ):
6+ if not settings .ENABLE_SERVER_PUSH :
7+ return response
8+
9+ response ['Link' ] = '</static/styles/index.css>; as=style; rel=preload'
10+ return response
Original file line number Diff line number Diff line change 3333# Application definition
3434
3535INSTALLED_APPS = (
36- 'django.contrib.admin' ,
36+ # 'django.contrib.admin',
3737 'django.contrib.auth' ,
3838 'django.contrib.contenttypes' ,
3939 'django.contrib.sessions' ,
4040 'django.contrib.messages' ,
4141 'django.contrib.staticfiles' ,
42+ 'applications.demo' ,
4243)
4344
4445MIDDLEWARE_CLASSES = (
5051 'django.contrib.messages.middleware.MessageMiddleware' ,
5152 'django.middleware.clickjacking.XFrameOptionsMiddleware' ,
5253 'django.middleware.security.SecurityMiddleware' ,
54+ 'applications.demo.middlewares.AddLinkHeaderMiddleware' ,
5355)
5456
5557ROOT_URLCONF = 'conf.urls'
104106STATIC_URL = '/static/'
105107STATIC_ROOT = str (BASE_DIR_PATH / 'static' )
106108STATICFILES_DIRS = [str (BASE_DIR_PATH / "applications/demo/static" )]
109+
110+ ENABLE_SERVER_PUSH = True
You can’t perform that action at this time.
0 commit comments