I have a django app that is serving video files that were uploaded by a user and saved. The videos that are 1 second and 2 seconds work and embed just fine, but the videos that are 24-27 seconds don't render and produce the following errors:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 86, in run
self.finish_response()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 128, in finish_response
self.write(data)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 217, in write
self._write(data)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 324, in write
self.flush()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
[10/Aug/2014 09:17:41] "GET /media/mbaron/video3.MOV HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 49384)
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 593, in process_request_thread
self.finish_request(request, client_address)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Python/2.7/site-packages/django/core/servers/basehttp.py", line 139, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 651, in __init__
self.finish()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 710, in finish
self.wfile.close()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 279, in close
self.flush()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
I'm rendering a video with the following code in my template:
<video controls="controls" width="800" height="600" name="Video Name" src="/media/{{ profile.video2 }}"></video>
Thanks for your help!
Related
I am completely new to Django/python so excuse any wrong vocabulary.
I have a Django based application that has been running perfectly on the HTTP protocol in an Ubuntu server. (Django is used both as App server and webserver here) I was asked to migrate the application from HTTP to the HTTPS protocol.
I have performed the below steps in the server.
Installed the following packages:
django-extensions, django-secure, and django-sslserver
Added 'sslserver' in setting.py under INSTALLED_APPS
Placed certificate and key in /etc/ssl/certs/ and /etc/ssl/private respectively
Start-up application with the command:
python3 manage.py runsslserver --certificate /etc/ssl/certs/my.cer --key /etc/ssl/private/my.key 172.31.83.127:8081 --configuration=uat
I have updated the CLB as below: -
[CLB Listener][1]
[CLB Health Check][2]
Now, when I run the command in the server I am getting below errors: -
File "/usr/lib/python3.5/wsgiref/handlers.py", line 138, in run
self.finish_response()
File "/usr/lib/python3.5/wsgiref/handlers.py", line 180, in finish_response
self.write(data)
File "/usr/lib/python3.5/wsgiref/handlers.py", line 279, in write
self._write(data)
File "/usr/lib/python3.5/wsgiref/handlers.py", line 453, in _write
result = self.stdout.write(data)
File "/usr/lib/python3.5/socket.py", line 593, in write
return self._sock.send(b)
File "/usr/lib/python3.5/ssl.py", line 861, in send
return self._sslobj.write(data)
File "/usr/lib/python3.5/ssl.py", line 586, in write
return self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1848)
[13/Jan/2020 17:54:54] "GET / HTTP/1.1" 500 59
Exception happened during processing of request from ('172.31.5.104', 33784)
Traceback (most recent call last):
File "/usr/lib/python3.5/wsgiref/handlers.py", line 138, in run
self.finish_response()
File "/usr/lib/python3.5/wsgiref/handlers.py", line 180, in finish_response
self.write(data)
File "/usr/lib/python3.5/wsgiref/handlers.py", line 279, in write
self._write(data)
File "/usr/lib/python3.5/wsgiref/handlers.py", line 453, in _write
result = self.stdout.write(data)
File "/usr/lib/python3.5/socket.py", line 593, in write
return self._sock.send(b)
File "/usr/lib/python3.5/ssl.py", line 861, in send
return self._sslobj.write(data)
File "/usr/lib/python3.5/ssl.py", line 586, in write
return self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1848)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/wsgiref/handlers.py", line 141, in run
self.handle_error()
File "/usr/local/lib/python3.5/dist-packages/django/core/servers/basehttp.py", line 116, in handle_error
super().handle_error()
File "/usr/lib/python3.5/wsgiref/handlers.py", line 368, in handle_error
self.finish_response()
File "/usr/lib/python3.5/wsgiref/handlers.py", line 180, in finish_response
self.write(data)
File "/usr/lib/python3.5/wsgiref/handlers.py", line 274, in write
self.send_headers()
File "/usr/lib/python3.5/wsgiref/handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "/usr/lib/python3.5/wsgiref/handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/socketserver.py", line 625, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python3.5/socketserver.py", line 354, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python3.5/socketserver.py", line 681, in init
self.handle()
File "/usr/local/lib/python3.5/dist-packages/django/core/servers/basehttp.py", line 169, in handle
self.handle_one_request()
File "/usr/local/lib/python3.5/dist-packages/django/core/servers/basehttp.py", line 194, in handle_one_request
handler.run(self.server.get_app())
File "/usr/lib/python3.5/wsgiref/handlers.py", line 144, in run
self.close()
File "/usr/local/lib/python3.5/dist-packages/django/core/servers/basehttp.py", line 111, in close
super().close()
File "/usr/lib/python3.5/wsgiref/simple_server.py", line 36, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
Any help here would be really appreciated.
Thanks
I have a web app I'm developing locally, part of the app uses cryptocompare.
Contrarily to my previous experience on using API in Django(because previously I've been able to get data from cryptocomapare through there API), I couldn't even print the data to the console, not to talk of template.
I have even checked different other means of doing this in python on YouTube and blogs, but I don't seem to miss anything too (at least as far as I'm concerned, but technically speaking something is wrong).
I have the app in the settings/installed-app.
I have my API key linked accordingly (at least as far as I can understand).
I have done the following to create the app in Django:
The crypto code is like this for Django:
import requests
def cryptos(request):
api_rqt = requests.get(
'https://min-api.cryptocompare.com/data/v2/news/?lang=EN&api_key={my-app-key)')
api = json.loads(api_rqt.content)
print(api_rqt)
context = {'api': api}
template = 'home.html'
return render(request, template, context)
<div>
{% for api in api.Data%}
<h4>{{api.title}}</h4>
<h5>By <label>|</label> <i>{{api.published_on}}</i></h5>
<p>{{api.body}}</p>
Read More ...
{% endfor %}
</div>
I expect the output to show me news summary from cryptocompare but nothing is shown. And my Django server is running very well.
I received some exception message:
Traceback (most recent call last):
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\socketserver.py", line 796, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
[27/Aug/2019 10:46:30] "GET /favicon.ico HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 53817)
Traceback (most recent call last):
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\socketserver.py", line 796, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\python-web-works\lib\site-packages\django\core\servers\basehttp.py", line 116, in handle_error
super().handle_error()
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\socketserver.py", line 647, in process_request_thread
self.finish_request(request, client_address)
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\socketserver.py", line 357, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\socketserver.py", line 717, in __init__
self.handle()
File "C:\python-web-works\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "C:\python-web-works\lib\site-packages\django\core\servers\basehttp.py", line 194, in handle_one_request
handler.run(self.server.get_app())
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\python-web-works\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
super().close()
File "c:\users\timilehin\appdata\local\programs\python\python37\Lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------
If I look at that data, then what you actually want to pass to the html template is :
context = {'api': api['Data']}
This is then a list of dictionaries that you can iterate over using:
{% for dict in api %}
You can then find the fields you want.
Alternatively, look at flattening the dictionaries to only the fields you want before passing everything as the context.
I'm running Django 2.17 and I get many many errors from the dev server, the terminal prints this error 5 or six times on every requestx to the dev server.
Trying to add --verbosity 0 to the runserver command does not supress them.
I want to print from functions in views, but I don't need the errors from django.
Someone on the django IRC channel told me that they were normal... but it looks as if something is not configured correctly to me.
EDITED IN:
Traceback (most recent call last):
File "c:\python\Lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "c:\python\Lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "c:\python\Lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "c:\python\Lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "c:\python\Lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "c:\python\Lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "c:\python\Lib\socketserver.py", line 796, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
Traceback (most recent call last):
File "c:\python\Lib\socketserver.py", line 647, in process_request_thread
self.finish_request(request, client_address)
File "c:\python\Lib\socketserver.py", line 647, in process_request_thread
self.finish_request(request, client_address)
File "c:\python\Lib\socketserver.py", line 357, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "c:\python\Lib\socketserver.py", line 357, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "c:\python\Lib\socketserver.py", line 717, in __init__
self.handle()
File "c:\python\Lib\socketserver.py", line 717, in __init__
self.handle()
File "C:\Python\virtualenvs\tools\lib\site-packages\django\core\servers\basehttp.py", line 151, in handle
self.handle_one_request()
File "C:\Python\virtualenvs\tools\lib\site-packages\django\core\servers\basehttp.py", line 153, in handle
self.handle_one_request()
File "C:\Python\virtualenvs\tools\lib\site-packages\django\core\servers\basehttp.py", line 176, in handle_one_request
handler.run(self.server.get_app())
File "C:\Python\virtualenvs\tools\lib\site-packages\django\core\servers\basehttp.py", line 176, in handle_one_request
handler.run(self.server.get_app())
File "c:\python\Lib\wsgiref\handlers.py", line 144, in run
self.close()
File "c:\python\Lib\wsgiref\handlers.py", line 144, in run
self.close()
File "c:\python\Lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
File "c:\python\Lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
AttributeError: 'NoneType' object has no attribute 'split'
--------------------------------------------------------------------------------
Looks like you are trying to split a variable that you expect to be str but which is somehow NoneType (None) instead.
I am using Django Rest Framework for the back-end and Angular 7 for the user interface. I'm trying to create a login page to my single page application and authenticate with a jwt token. I've already managed the back-end and it works. Whenever i go to /api-token-auth/ and type the credentials i get a token in the rest framework interface.
The front-end part though troubles me. I have created the login component, the authorization service and a token interceptor. I believe i did the right adjustments but whenever i try to login from angular this error appears in the django command promt.
"Bad Request: /api-token-auth/ [19/Nov/2018 20:16:16] "POST
/api-token-auth/ HTTP/1.1" 400 68 Traceback (most recent call last):
File "C:\Python36\lib\wsgiref\handlers.py", line 138, in run
self.finish_response() File "C:\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data) File "C:\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers() File "C:\Python36\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble() File "C:\Python36\lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1') File
"C:\Python36\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data) File "C:\Python36\lib\socketserver.py", line 775, in write
self._sock.sendall(b) ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host
machine [19/Nov/2018 20:16:16] "POST /api-token-auth/ HTTP/1.1" 500 59
---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 51566) Traceback (most recent
call last): File "C:\Python36\lib\wsgiref\handlers.py", line 138, in
run
self.finish_response() File "C:\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data) File "C:\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers() File "C:\Python36\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble() File "C:\Python36\lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1') File
"C:\Python36\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data) File "C:\Python36\lib\socketserver.py", line 775, in write
self._sock.sendall(b) ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host
machine
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Python36\lib\wsgiref\handlers.py", line 141, in run
self.handle_error() File "C:\Python36\lib\site-packages\django\core\servers\basehttp.py", line
86, in handle_error
super().handle_error() File "C:\Python36\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response() File "C:\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data) File "C:\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers() File "C:\Python36\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern(): File "C:\Python36\lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9' TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Python36\lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address) File "C:\Python36\lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self) File "C:\Python36\lib\socketserver.py", line 696, in init
self.handle() File "C:\Python36\lib\site-packages\django\core\servers\basehttp.py", line
154, in handle
handler.run(self.server.get_app()) File "C:\Python36\lib\wsgiref\handlers.py", line 144, in run
self.close() File "C:\Python36\lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent AttributeError: 'NoneType' object has no attribute 'split'"
I'm really trying to understand what is going on based in this error. Anybody has an idea? Thanks
UPDATE
I had never imported the FormsModuls and apparently that was causing the issue.
line 35, in close self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
Due to some reason, the attribute self.status is returning None which cannot be split, thus, causing errors.
When I test django by the selenium, the message "ERROR:textfield.h(162)] NOT IMPLEMENTED" can be found。Smoetimes it's
[6952:4828:0813/120624:ERROR:textfield.h(162)] NOT IMPLEMENTED
Traceback (most recent call last):
File "d:\Python27\lib\wsgiref\handlers.py", line 86, in run
self.finish_response()
File "d:\Python27\lib\wsgiref\handlers.py", line 127, in finish_response
self.write(data)
File "d:\Python27\lib\wsgiref\handlers.py", line 210, in write
self.send_headers()
File "d:\Python27\lib\wsgiref\handlers.py", line 268, in send_headers
self.send_preamble()
File "d:\Python27\lib\wsgiref\handlers.py", line 192, in send_preamble
'Date: %s\r\n' % format_date_time(time.time())
File "d:\Python27\lib\socket.py", line 324, in write
self.flush()
File "d:\Python27\lib\socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053]
Traceback (most recent call last):
File "d:\Python27\lib\site-packages\django\test\testcases.py", line 981, in _h
andle_request_noblock
self.process_request(request, client_address)
File "d:\Python27\lib\SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "d:\Python27\lib\SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "d:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 139
, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "d:\Python27\lib\SocketServer.py", line 640, in __init__
self.finish()
File "d:\Python27\lib\SocketServer.py", line 693, in finish
self.wfile.flush()
File "d:\Python27\lib\socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053]
.[4828:7168:0813/120645:ERROR:ipc_channel_win.cc(132)] pipe error: 109
[4916:6692:0813/120647:ERROR:textfield.h(162)] NOT IMPLEMENTED
.
----------------------------------------------------------------------
Ran 2 tests in 48.504s
OK
Creating test database for alias 'default'...
----------------------------------------`
but othertime it's
[7292:6276:0813/120013:ERROR:textfield.h(162)] NOT IMPLEMENTED
[7172:7500:0813/120022:ERROR:ipc_channel_win.cc(132)] pipe error: 109
.[7500:3040:0813/120036:ERROR:textfield.h(162)] NOT IMPLEMENTED
.
----------------------------------------------------------------------
Ran 2 tests in 47.570s
OK
Creating test database for alias 'default'...
Destroying test database for alias 'default'...