o
    4ήc?                     @   sD  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	 d dl
Z
d dlmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZmZ d dlmZmZ ej rcd dl!m"Z" e#e$e% Z&e#e$e% Z'e#e$e% Z(e#e$e% Z)e#dd e% D Z*e#eZ+d	Z,e-d
Z.dej/dej0de1ddfddZ2ej3ddide4dej5de6ddddej5de7ddddej5de6dddej5d e7dd!dej5d"dd#d$d%ej5d&d'dd(ej8dd)d*ej5d+d,dd-d.ej5d/d0dd1d.ej5d2e9d3dd4d5ej5d6de7d7d8ej5d9e*d:d;ddej5d<e'd:d=ddej5d>e(d:d?ddej5d@e7dAdBddej5dCe9dDdEddej5dFe9dDdGddej5dHe1ddIddej5dJe)d:dKddej5dLe+d:dMddej5dNej8dd)ddOddej5dPej8dd)ddQddej5dRe&ddSddej5dTdddUd%ej5dVdddWd%ej5dXdddYd%ej5dZddd[d%ej5d\ddd]d%ej5d^e6dd_dej5d`e6dadbdej5dce7ddddej5dee7dfdgdej5dhe7ddidej5dje7dkdlddej5dme6ddnddej5doe6ddpddej5dqe6ddrddej5dse7e7edtddej5due7e7ej:dvddej5dwe6ddxddej5dye6dzd{ddej5d|d}dd~d.ej5dde2d#dddej5dddddej5dde7e	ddej5ddd#dddde6de6de7de6de7dededede7de9de9de1dedede1d'ej;e6 d,ej;e6 d0ej;e6 de9de7de6de6de6de1de1de1de1de6de6de7de7de7de7de6de6de6de7de7de6de6d}ej;e6 de1de6de7de1ddf\ddZ<ddddd:d:d:dAdDdDdd:d:d#dddd3ddedddddddaddfddkdddeej:ddzdddd#e	d,dej=dej>e6f de6de7dej?e6 dej?e7 dedej=ej@e jA ef dej=ej@e jA ef de7dej?e9 dej?e9 de1dedede1d'ej?ej=ej;e6 e6f  d,ej?ej=ej;e6 e6f  d0ej?ej=ej;e6 e6f  de9dej?e7 dej?ej=e6ejBf  dej?ej=ejCe6ejDf e6f  dej?ej=e6e7f  de1de1de1de1dej?ej=ej;e6 e6f  de6dej?e7 de7dej?e7 de7dej?e6 dej?ej=e6ejBf  dej?e6 de7de7dej?e6 de6d}ej?ej;ejEe6e6f   dej?e1 dej?e6 de1de7ddf\ddZFeGdkr e<  dS dS )    N)!DEFAULT_MAX_INCOMPLETE_EVENT_SIZE)HTTP_PROTOCOLS
INTERFACESLIFESPAN
LOG_LEVELSLOGGING_CONFIGLOOP_SETUPSSSL_PROTOCOL_VERSIONWS_PROTOCOLSConfigHTTPProtocolTypeInterfaceTypeLifespanTypeLoopSetupTypeWSProtocolType)ServerServerState)ChangeReloadMultiprocess)ASGIApplicationc                 C   s   g | ]}|d kr|qS )none ).0keyr   r   3/tmp/pip-target-vg8gfxp4/lib/python/uvicorn/main.py
<listcomp>'       r      uvicorn.errorctxparamvaluereturnc                 C   s>   |r| j rd S tdtjt t t f  | 	  d S )Nz#Running uvicorn %s with %s %s on %s)
resilient_parsingclickechouvicorn__version__platformpython_implementationpython_versionsystemexit)r   r    r!   r   r   r   print_version/   s   
	r-   auto_envvar_prefixUVICORN)context_settingsappz--hostz	127.0.0.1zBind socket to this host.T)typedefaulthelpshow_defaultz--porti@  zBind socket to this port.z--udszBind to a UNIX domain socket.)r2   r3   r4   z--fdz)Bind to socket from this file descriptor.z--reloadFzEnable auto-reload.)is_flagr3   r4   z--reload-dirreload_dirszRSet reload directories explicitly, instead of using the current working directory.)exists)multipler4   r2   z--reload-includereload_includeszSet glob patterns to include while watching for files. Includes '*.py' by default; these defaults can be overridden with `--reload-exclude`. This option has no effect unless watchfiles is installed.)r9   r4   z--reload-excludereload_excludeszSet glob patterns to exclude while watching for files. Includes '.*, .py[cod], .sw.*, ~*' by default; these defaults can be overridden with `--reload-include`. This option has no effect unless watchfiles is installed.z--reload-delayg      ?zTDelay between previous and next check if application needs to be. Defaults to 0.25s.)r2   r3   r5   r4   z	--workersz~Number of worker processes. Defaults to the $WEB_CONCURRENCY environment variable if available, or 1. Not valid with --reload.)r3   r2   r4   z--loopautozEvent loop implementation.z--httpzHTTP protocol implementation.z--wsz"WebSocket protocol implementation.z--ws-max-sizei   z#WebSocket max size message in bytesz--ws-ping-intervalg      4@zWebSocket ping intervalz--ws-ping-timeoutzWebSocket ping timeoutz--ws-per-message-deflatez)WebSocket per-message-deflate compressionz
--lifespanzLifespan implementation.z--interfacez:Select ASGI3, ASGI2, or WSGI as the application interface.z
--env-filezEnvironment configuration file.z--log-configzBLogging configuration file. Supported formats: .ini, .json, .yaml.z--log-levelzLog level. [default: info]z--access-log/--no-access-logzEnable/Disable access log.z--use-colors/--no-use-colorsz!Enable/Disable colorized logging.z"--proxy-headers/--no-proxy-headerszdEnable/Disable X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to populate remote address info.z"--server-header/--no-server-headerz%Enable/Disable default Server header.z--date-header/--no-date-headerz#Enable/Disable default Date header.z--forwarded-allow-ipszComma separated list of IPs to trust with proxy headers. Defaults to the $FORWARDED_ALLOW_IPS environment variable if available, or '127.0.0.1'.z--root-path zLSet the ASGI 'root_path' for applications submounted below a given URL path.z--limit-concurrencyz^Maximum number of concurrent connections or tasks to allow, before issuing HTTP 503 responses.z	--backlogi   z0Maximum number of connections to hold in backlogz--limit-max-requestszEMaximum number of requests to service before terminating the process.z--timeout-keep-alive   zLClose Keep-Alive connections if no new data is received within this timeout.z--ssl-keyfilezSSL key filez--ssl-certfilezSSL certificate filez--ssl-keyfile-passwordzSSL keyfile passwordz--ssl-versionz,SSL version to use (see stdlib ssl module's)z--ssl-cert-reqsz@Whether client certificate is required (see stdlib ssl module's)z--ssl-ca-certszCA certificates filez--ssl-ciphersTLSv1z(Ciphers to use (see stdlib ssl module's)z--headerheaderszASpecify custom default HTTP response headers as a Name:Value pairz	--versionz%Display the uvicorn version and exit.)r6   callbackexpose_valueis_eagerr4   z	--app-dir.zuLook for APP in the specified directory, by adding this to the PYTHONPATH. Defaults to the current working directory.)r3   r5   r4   z--h11-max-incomplete-event-sizeh11_max_incomplete_event_sizezFFor h11, the maximum number of bytes to buffer of an incomplete event.z	--factoryzFTreat APP as an application factory, i.e. a () -> <ASGI app> callable.)r6   r3   r4   r5   hostportudsfdloophttpwsws_max_sizews_ping_intervalws_ping_timeoutws_per_message_deflatelifespan	interfacereloadreload_delayworkersenv_file
log_config	log_level
access_logproxy_headersserver_headerdate_headerforwarded_allow_ips	root_pathlimit_concurrencybackloglimit_max_requeststimeout_keep_alivessl_keyfilessl_certfilessl_keyfile_passwordssl_versionssl_cert_reqsssl_ca_certsssl_ciphers
use_colorsapp_dirfactoryc-           -      C   s  t | fi d|d|d|d|d|d|d|d|d	|	d
|
d|d|d|d|d u r2tn|d|d|d|d|d|pDd d|pId d|pd d|d|d|d|d|d|d|d|d|d|d | d!|!d"|"d#|#d$|$d%|%d&|&d'|'d(d)d* |(D d+|)d,|,d-|*d.|+ d S d|d|d|d|d|d|d|d|d|d|d | d!|!d"|"d#|#d$|$d%|%d&|&d'|'d(d)d* |(D d+|)d,|,d-|*d.|+ d S )/NrF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rV   rW   rX   rY   rR   rS   r7   r:   r;   rT   rU   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   r@   c                 S   s   g | ]}| d dqS ):   )split)r   headerr   r   r   r     r   zmain.<locals>.<listcomp>rj   rl   rk   rE   )runr   )-r1   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   r7   r:   r;   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   r@   rj   rk   rE   rl   r   r   r   main>   s     X	
 !"#$%&'()*+,- !"#$%&'()*+,-rr   ),rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   r7   r:   r;   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   r@   rj   rk   rl   rE   r   c       ,   1      C   s  |*d urt jd|* t| fi d|d|d|d|d|d|d|d	|d
|	d|
d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d |d!| d"|!d#|"d$|#d%|$d&|%d'|&d(|'d)|(d*|)d+|+d,|,}-t|-d-}.|-js|-jd.krt| tst	
d/}/|/d0 t d. |-jr|- }0t|-|.j|0gd1  n|-jd.kr|- }0t|-|.j|0gd1  n|.  |-jrtj|-jrt|-j |.js|-js|-jd.krt t d S d S d S d S )2Nr   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   r7   r:   r;   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   r@   rj   rl   rE   )configrn   r   zRYou must pass the application as an import string to enable 'reload' or 'workers'.)targetsockets)syspathinsertr   r   rS   rU   
isinstancestrlogging	getLoggerwarningr,   should_reloadbind_socketr   rq   r   rH   osr8   removestartedSTARTUP_FAILURE)1r1   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   r7   r:   r;   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   r@   rj   rk   rl   rE   rs   serverloggersockr   r   r   rq     s   2	
 !"#$%&'()*+,
.


rq   __main__)Hasyncior{   r   r(   sslrv   typingr$   h11._connectionr   r&   uvicorn.configr   r   r   r   r   r   r	   r
   r   r   r   r   r   r   uvicorn.serverr   r   uvicorn.supervisorsr   r   TYPE_CHECKINGasgiref.typingr   ChoicelistkeysLEVEL_CHOICESHTTP_CHOICES
WS_CHOICESLIFESPAN_CHOICESLOOP_CHOICESINTERFACE_CHOICESr   r|   r   Context	Parameterboolr-   commandargumentoptionrz   intPathfloat	CERT_NONEListrr   UnionCallableOptionalTypeProtocolPathLikeDictAnyTuplerq   __name__r   r   r   r   <module>   s<   @


	


	
 !"#$%&'()*+,-.hc	
 !"#$%&'()*+,-./01

|
