File: //usr/lib/python3/dist-packages/django/core/servers/__pycache__/basehttp.cpython-310.pyc
o
3�a" � @ s� d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m
Z
ddlmZ ddl
mZ dZe�d �Zd
d� Zdd
� ZG dd� dej�ZG dd� deje�ZG dd� dej�ZG dd� dej�Zddefdd�ZdS )a0
HTTP server that implements the Python WSGI protocol (PEP 333, rev 1.21).
Based on wsgiref.simple_server which is part of the standard library since 2.5.
This is a simple server for use in testing or debugging Django apps. It hasn't
been reviewed for security issues. DON'T USE IT FOR PRODUCTION USE!
� N)�
simple_server)�ImproperlyConfigured)�
LimitedStream)�get_wsgi_application)�
import_string)�
WSGIServer�WSGIRequestHandlerz
django.serverc
C sV ddl m} t| d�}|du rt� S zt|�W S ty* } ztd| �|�d}~ww )aK
Load and return the WSGI application as configured by the user in
``settings.WSGI_APPLICATION``. With the default ``startproject`` layout,
this will be the ``application`` object in ``projectname/wsgi.py``.
This function, and the ``WSGI_APPLICATION`` setting itself, are only useful
for Django's internal server (runserver); external WSGI servers should just
be configured to point to the correct application object directly.
If settings.WSGI_APPLICATION is not set (is ``None``), return
whatever ``django.core.wsgi.get_wsgi_application`` returns.
r )�settings�WSGI_APPLICATIONNzBWSGI application '%s' could not be loaded; Error importing module.)�django.confr �getattrr r �ImportErrorr )r �app_path�err� r �>/usr/lib/python3/dist-packages/django/core/servers/basehttp.py�get_internal_wsgi_application s
�����r c C s t �� \} }}t| tttf�S �N)�sys�exc_info�
issubclass�BrokenPipeError�ConnectionAbortedError�ConnectionResetError)�exc_type�_r r r �is_broken_pipe_error5 s �r c s8 e Zd ZdZdZddd�� fdd�
Z� fdd �Z� ZS )
r z7BaseHTTPServer that implements the Python WSGI protocol�
FT)�ipv6�allow_reuse_addressc s( |rt j| _|| _t� j|i |�� d S r )�socket�AF_INET6�address_familyr �super�__init__)�selfr r �args�kwargs�� __class__r r r$ C s zWSGIServer.__init__c s( t � rt�d|� d S t� �||� d S )Nz- Broken pipe from %s
)r �logger�infor# �handle_error)r% �request�client_addressr( r r r, I s zWSGIServer.handle_error)�__name__�
__module__�__qualname__�__doc__�request_queue_sizer$ r, �
__classcell__r r r( r r >