Skip to content

Commit 5a2deab

Browse files
authored
Merge pull request #492 from liangliangyy/dev
升级依赖,fix #491
2 parents bb90743 + 818b16a commit 5a2deab

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ WORKDIR /code/DjangoBlog/
44
RUN apt-get install default-libmysqlclient-dev -y && \
55
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
66
ADD requirements.txt requirements.txt
7-
RUN pip install -Ur requirements.txt && \
7+
RUN pip install --upgrade pip && \
8+
pip install -Ur requirements.txt && \
89
pip install gunicorn[gevent] && \
910
pip cache purge
1011

blog/middleware.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ def __call__(self, request):
3434
http_user_agent = request.META.get('HTTP_USER_AGENT', '')
3535
ip, _ = get_client_ip(request)
3636
user_agent = parse(http_user_agent)
37-
38-
try:
39-
cast_time = time.time() - start_time
40-
if ELASTICSEARCH_ENABLED:
41-
time_taken = round((cast_time) * 1000, 2)
42-
url = request.path
43-
from django.utils import timezone
44-
ElaspedTimeDocumentManager.create(
45-
url=url,
46-
time_taken=time_taken,
47-
log_datetime=timezone.now(),
48-
useragent=user_agent,
49-
ip=ip)
50-
response.content = response.content.replace(
51-
b'<!!LOAD_TIMES!!>', str.encode(str(cast_time)[:5]))
52-
except Exception as e:
53-
logger.error("Error OnlineMiddleware: %s" % e)
37+
if not response.streaming:
38+
try:
39+
cast_time = time.time() - start_time
40+
if ELASTICSEARCH_ENABLED:
41+
time_taken = round((cast_time) * 1000, 2)
42+
url = request.path
43+
from django.utils import timezone
44+
ElaspedTimeDocumentManager.create(
45+
url=url,
46+
time_taken=time_taken,
47+
log_datetime=timezone.now(),
48+
useragent=user_agent,
49+
ip=ip)
50+
response.content = response.content.replace(
51+
b'<!!LOAD_TIMES!!>', str.encode(str(cast_time)[:5]))
52+
except Exception as e:
53+
logger.error("Error OnlineMiddleware: %s" % e)
5454

5555
return response

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ django-haystack==3.0
55
django-ipware==3.0.2
66
django-mdeditor==0.1.18
77
django-uuslug==1.2.0
8-
elasticsearch==7.13.2
9-
elasticsearch-dsl==7.3.0
8+
elasticsearch==7.13.3
9+
elasticsearch-dsl==7.4.0
1010
gevent==21.1.2
1111
jieba==0.42.1
1212
jsonpickle==2.0.0

0 commit comments

Comments
 (0)