我有一些gzip压缩数据,但缺少gzip标头,我是手动添加的。
Environment:
Request Method: GET
Request URL: https://www.echobatalog.com/
Django Version: 2.2
Python Version: 3.6.7
Installed Applications:
['app',
'material',
'material.admin',
'imagekit',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sitemaps',
'django.contrib.sites',
'django_celery_results']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'material.frontend.middleware.SmoothNavigationMiddleware']
Template error:
In template /home/batalog/batalogvenv/Bat_Echolocation_2019/app/templates/layout.html, error at line 3
Reverse for 'render-status' not found. 'render-status' is not a valid view function or pattern name.
1 : <script type="text/javascript">// <![CDATA[
2 : function get_status() {
3 : var urlStatus = ' {% url "render-status" %} ';
4 : fetch(urlStatus).then(function(response) {
5 : response.json().then(function(data) {
6 : if(data.status) {
7 : // show render link
8 : // don't forget to hide on click
9 : }
10 : else {
11 : // show loading gif
12 : }
13 : });
Traceback:
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/batalog/batalogvenv/Bat_Echolocation_2019/app/views.py" in gallery
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/shortcuts.py" in render
36. content = loader.render_to_string(template_name, context, request, using=using)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/loader.py" in render_to_string
62. return template.render(context, request)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/backends/django.py" in render
61. return self.template.render(context)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/base.py" in render
171. return self._render(context)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/base.py" in _render
163. return self.nodelist.render(context)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/base.py" in render
937. bit = node.render_annotated(context)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/base.py" in render_annotated
904. return self.render(context)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/loader_tags.py" in render
150. return compiled_parent._render(context)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/base.py" in _render
163. return self.nodelist.render(context)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/base.py" in render
937. bit = node.render_annotated(context)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/base.py" in render_annotated
904. return self.render(context)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/loader_tags.py" in render
150. return compiled_parent._render(context)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/base.py" in _render
163. return self.nodelist.render(context)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/base.py" in render
937. bit = node.render_annotated(context)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/base.py" in render_annotated
904. return self.render(context)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/template/defaulttags.py" in render
443. url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/urls/base.py" in reverse
90. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/home/batalog/batalogvenv/lib/python3.6/site-packages/django/urls/resolvers.py" in _reverse_with_prefix
660. raise NoReverseMatch(msg)
Exception Type: NoReverseMatch at /
Exception Value: Reverse for 'render-status' not found. 'render-status' is not a valid view function or pattern name.
解压缩gzip_header = u'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x00'
gzip_body = u'\x95\x93\xdfn\xe3D\x18\xc5q\xebv\xb3\xb4\xbb\x80\xb4H+\x84P\x05W,$\xf....'
gzip_content = gzip_header + gzip_body
unziped = .... ?
print unziped
的正确方法是什么?