U
    RhB                  b   @  sz  d dl m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
mZmZmZ d dlZd dlZd dlm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'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Z0e1dZ2dddddddZ3ej4ddidej5dddej6de7ddddej6de8d d!ddej6d"e7dd#d$ej6d%e8dd&d$ej6d'dd(d)d*ej6d+d,dd-ej9dd.d/ej6d0d1dd2d3ej6d4d5dd6d3ej6d7e:d8dd9d:ej6d;de8d<d=ej6d>e.d?d@ddej6dAe+d?dBddej6dCe,d?dDddej6dEe8dFdGddej6dHe8dIdJddej6dKe:dLdMddej6dNe:dLdOddej6dPe;ddQddej6dRe-d?dSddej6dTe/d?dUddej6dVej9dd.ddWddej6dXej9dd.ddYddej6dZe*dd[ddej6d\ddd]d*ej6d^ddd_d*ej6d`dddad*ej6dbdddcd*ej6ddddded*ej6dfe7ddgd$ej6dhe7didjd$ej6dke8ddld$ej6dme8dndod$ej6dpe8ddqd$ej6dre8dsdtddej6due8ddvd$ej6dwe7ddxddej6dye7ddzddej6d{e7dd|ddej6d}e8e8ed~ddej6de8e8ej<dddej6de7ddddej6de7ddddej6ddddd3ej6dde3d(dddej6ddidddej6dde8ddd$ej6ddd(dddddddddddddddddddddddddddddddddddddddddddddddddddd0ddZ=dd ddd?d?d?dFdIdLdLdd?d?d(dddd8ddedddddddiddnddsddddeej<dddddd(dd.ddddddddddddddddddddddddddddddddddddddddddddddddd0ddZ>e?dkrve=  dS )    )annotationsN)RawConfigParser)IOAnyCallable)ASGIApplication)HTTP_PROTOCOLS
INTERFACESLIFESPAN
LOG_LEVELSLOGGING_CONFIGLOOP_SETUPSSSL_PROTOCOL_VERSIONWS_PROTOCOLSConfigHTTPProtocolTypeInterfaceTypeLifespanTypeLoopSetupTypeWSProtocolType)ServerServerState)ChangeReloadMultiprocessc                 C  s   g | ]}|d kr|qS )Znone ).0keyr   r   2./venv/lib/python3.8/site-packages/uvicorn/main.py
<listcomp>'   s      r      uvicorn.errorzclick.Contextzclick.ParameterboolNone)ctxparamvaluereturnc                 C  s@   |r
| j rd S tdjtjt t t	 d | 
  d S )NzKRunning uvicorn {version} with {py_implementation} {py_version} on {system})versionZpy_implementationZ
py_versionsystem)Zresilient_parsingclickZechoformatuvicorn__version__platformZpython_implementationZpython_versionr(   exit)r#   r$   r%   r   r   r   print_version/   s    
r/   Zauto_envvar_prefixZUVICORN)Zcontext_settingsappZUVICORN_APP)Zenvvarz--hostz	127.0.0.1zBind socket to this host.T)typedefaulthelpshow_defaultz--porti@  zABind socket to this port. If 0, an available port will be picked.z--udszBind to a UNIX domain socket.)r1   r2   r3   z--fdz)Bind to socket from this file descriptor.z--reloadFzEnable auto-reload.)is_flagr2   r3   z--reload-dirreload_dirszRSet reload directories explicitly, instead of using the current working directory.)exists)multipler3   r1   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.)r8   r3   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.)r1   r2   r4   r3   z	--workersz~Number of worker processes. Defaults to the $WEB_CONCURRENCY environment variable if available, or 1. Not valid with --reload.)r2   r1   r3   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-max-queue    z2The maximum length of the WebSocket message queue.z--ws-ping-intervalg      4@z#WebSocket ping interval in seconds.z--ws-ping-timeoutz"WebSocket ping timeout in seconds.z--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 IP Addresses, IP Networks, or literals (e.g. UNIX Socket path) to trust with proxy headers. Defaults to the $FORWARDED_ALLOW_IPS environment variable if available, or '127.0.0.1'. The literal '*' means trust everything.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--timeout-graceful-shutdownz8Maximum number of seconds to wait for graceful shutdown.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-ciphersZ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.)r5   callbackZexpose_valueZis_eagerr3   z	--app-dirzuLook for APP in the specified directory, by adding this to the PYTHONPATH. Defaults to the current working directory.)r2   r4   r3   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.)r5   r2   r3   r4   strintr   r   r   floatr   r   z	list[str]z
int | None)0r0   hostportudsfdloophttpwsws_max_sizews_max_queuews_ping_intervalws_ping_timeoutws_per_message_deflatelifespan	interfacereloadr6   r9   r:   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timeout_graceful_shutdownssl_keyfilessl_certfilessl_keyfile_passwordssl_versionssl_cert_reqsssl_ca_certsssl_ciphersr?   
use_colorsapp_dirrA   factoryr&   c/           /   1   C  s   t | |||||||||	|
|||||d kr,tn||||||p<d |pBd |pHd |||||||||| |!|"|#|$|%|&|'|(|)dd |*D |+|.|,|-d/ d S )Nc                 S  s   g | ]}| d dqS ):   )split)r   headerr   r   r   r     s     zmain.<locals>.<listcomp>).rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rV   rW   rX   rY   rR   rS   r6   r9   r:   rT   rU   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   r?   rk   rm   rl   rA   )runr   )/r0   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   r6   r9   r:   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   r?   rk   rl   rA   rm   r   r   r   main=   sf      ars   ).rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   r6   r9   r:   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   r?   rk   rl   rm   rA   z*ASGIApplication | Callable[..., Any] | strz
str | Nonez)type[asyncio.Protocol] | HTTPProtocolTypez'type[asyncio.Protocol] | WSProtocolTypezfloat | Nonezlist[str] | str | Nonezstr | os.PathLike[str] | Nonez7dict[str, Any] | str | RawConfigParser | IO[Any] | Nonezstr | int | Nonezlist[tuple[str, str]] | Nonezbool | None)0r0   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   r6   r9   r:   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   r?   rk   rl   rm   rA   r&   c       .   3   0   C  s  |,d k	rt jd|, t| |||||||||	|
|||||||||||||||||||||| |!|"|#|$|%|&|'|(|)|*|+|-|.d.}/t|/d}0|/js|/jdkrt| tst	
d}1|1d t d zzz^|/jr|/ }2t|/|0j|2gd  n4|/jdkr|/ }2t|/|0j|2gd  n|0  W n tk
r2   Y nX W 5 |/jr\tj|/jr\t|/j X |0js|/js|/jdkrt t d S )Nr   )-rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   r6   r9   r:   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   r?   rk   rm   rA   )configro   r    zRYou must pass the application as an import string to enable 'reload' or 'workers'.)targetZsockets)syspathinsertr   r   rS   rU   
isinstancerB   logging	getLoggerZwarningr.   rG   osr7   removeZshould_reloadZbind_socketr   rr   r   KeyboardInterruptstartedSTARTUP_FAILURE)3r0   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   r6   r9   r:   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   r?   rk   rl   rm   rA   rt   ZserverloggerZsockr   r   r   rr     s    20




rr   __main__)@Z
__future__r   Zasynciorz   r|   r-   Zsslrv   configparserr   typingr   r   r   r)   r+   Zuvicorn._typesr   Zuvicorn.configr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   Zuvicorn.serverr   r   Zuvicorn.supervisorsr   r   ZChoicelistkeysZLEVEL_CHOICESZHTTP_CHOICESZ
WS_CHOICESZLIFESPAN_CHOICESZLOOP_CHOICESZINTERFACE_CHOICESr   r{   r   r/   ZcommandargumentoptionrB   rC   PathrD   r!   Z	CERT_NONErs   rr   __name__r   r   r   r   <module>   s  @


	

	gp
