
    RPf>$                     ~   d dl mZ d dlmZ d dlmZmZ d dlZd dlm	Z	 d dl
mZ d dlmZ d dlmZ d d	lmZ d d
lmZ ddlmZ ddl mZ  ej.                  d      Z e         ee      Z	 d dlZdeddfdZej?                         	 d6deeedf    ej@                  dde      f   ddfd       Z	 d6dddddddddeedf   de!d e"d!ed"ee"df   d#e!d$e!d%ee!df   d&eddfd'Z#ejI                         	 d6ddddddd(deeedf    ejJ                  d)*      f   dee! ej@                  d+*      f   d ee" ej@                  d,*      f   d!ee ej@                  d-*      f   d#ee! ej@                  d.*      f   d%eee!df    ej@                  d/*      f   d&ee ej@                  d0*      f   defd1       Z&ejI                         	 d6d2ddddddddeeedf    ejJ                  d)*      f   dee! ej@                  d+*      f   d ee" ej@                  d,*      f   d!ee ej@                  d-*      f   d"eee"df    ej@                  d3*      f   d#ee! ej@                  d.*      f   d%eee!df    ej@                  d/*      f   d&ee ej@                  d0*      f   defd4       Z'd7d5Z(y# e$ r dZY Kw xY w)8    )	getLogger)Path)AnyUnionN)print)Padding)Panel)	Annotated)get_import_string)FastAPICLIException   )__version__)setup_loggingrich)rich_markup_modevaluereturnc                 V    | r't        dt         d       t        j                         y )NzFastAPI CLI version: [green]z[/green])r   r   typerExit)r   s    I/var/www/fastapitest/venv/lib/python3.12/site-packages/fastapi_cli/cli.pyversion_callbackr      s(    ,[MBCjjl     versionz	--versionzShow the version and exit.)helpcallbackc                      y)u   
    FastAPI CLI - The [bold]fastapi[/bold] command line app. 😎

    Manage your [bold]FastAPI[/bold] projects, run your FastAPI apps, and more.

    Read more in the docs: [link]https://fastapi.tiangolo.com/fastapi-cli/[/link].
    N )r   s    r   r   r   "   s    r   z	127.0.0.1i@  T F)hostportreloadworkers	root_pathappproxy_headerspathr    r!   r"   r#   r$   commandr%   r&   c          	         	 t        | |      }	d| d| d| d| d	}|dk(  rt        | d	d
ddd      }nt        | ddddd      }t        t        |d             t        st        d      d t        j                  |	||||||       y # t        $ r:}
t        j                  t	        |
             t        j                  d      d d }
~
ww xY w)N)r'   app_namer   )codez$[dim]Serving at:[/dim] [link]http://:z+[/link]

[dim]API docs:[/dim] [link]http://z/docs[/link]devzR

[dim]Running in development mode, for production use:[/dim] 

[b]fastapi run[/b]zFastAPI CLI - Development modeF)r      zblack on yellow)titleexpandpaddingstylezR

[dim]Running in production mode, for development use:[/dim] 

[b]fastapi dev[/b]zFastAPI CLI - Production modegreenz;Could not import Uvicorn, try running 'pip install uvicorn')r%   r    r!   r"   r#   r$   r&   )r   r   loggererrorstrr   r   r	   r   r   uvicornrun)r'   r    r!   r"   r#   r$   r(   r%   r&   use_uvicorn_appeserving_strpanels                r   _runr=   4   s   ++D 9avErswrxxyz~y  @L  MK%mqr2#
 mqr1
 
'%
!I
	 KK#5  +SVjja d*+s   B 	C5CC)r    r!   r"   r$   r%   r&   zA path to a Python file or package directory (with [blue]__init__.py[/blue] files) containing a [bold]FastAPI[/bold] app. If not provided, a default set of paths will be tried.)r   zThe host to serve on. For local development in localhost use [blue]127.0.0.1[/blue]. To enable public access, e.g. in a container, use all the IP addresses available with [blue]0.0.0.0[/blue].zThe port to serve on. You would normally have a termination proxy on top (another program) handling HTTPS on port [blue]443[/blue] and HTTP on port [blue]80[/blue], transferring the communication to your app.zEnable auto-reload of the server when (code) files change. This is [bold]resource intensive[/bold], use it only during development.zThe root path is used to tell your app that it is being served to the outside world with some [bold]path prefix[/bold] set up in some termination proxy or similar.zThe name of the variable that contains the [bold]FastAPI[/bold] app in the imported module or package. If not provided, it is detected automatically.zdEnable/Disable X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to populate remote address info.c          
      *    t        | |||||d|       y)u  
    Run a [bold]FastAPI[/bold] app in [yellow]development[/yellow] mode. 🧪

    This is equivalent to [bold]fastapi run[/bold] but with [bold]reload[/bold] enabled and listening on the [blue]127.0.0.1[/blue] address.

    It automatically detects the Python module or package that needs to be imported based on the file or directory path passed.

    If no path is passed, it tries with:

    - [blue]main.py[/blue]
    - [blue]app.py[/blue]
    - [blue]api.py[/blue]
    - [blue]app/main.py[/blue]
    - [blue]app/app.py[/blue]
    - [blue]app/api.py[/blue]

    It also detects the directory that needs to be added to the [bold]PYTHONPATH[/bold] to make the app importable and adds it.

    It detects the [bold]FastAPI[/bold] app object to use. By default it looks in the module or package for an object named:

    - [blue]app[/blue]
    - [blue]api[/blue]

    Otherwise, it uses the first [bold]FastAPI[/bold] app found in the imported module or package.
    r-   )r'   r    r!   r"   r$   r%   r(   r&   Nr=   )r'   r    r!   r"   r$   r%   r&   s          r   r-   r-   g   s%    N 	#	r   z0.0.0.0zIUse multiple worker processes. Mutually exclusive with the --reload flag.c                ,    t        | ||||||d|	       y)u  
    Run a [bold]FastAPI[/bold] app in [green]production[/green] mode. 🚀

    This is equivalent to [bold]fastapi dev[/bold] but with [bold]reload[/bold] disabled and listening on the [blue]0.0.0.0[/blue] address.

    It automatically detects the Python module or package that needs to be imported based on the file or directory path passed.

    If no path is passed, it tries with:

    - [blue]main.py[/blue]
    - [blue]app.py[/blue]
    - [blue]api.py[/blue]
    - [blue]app/main.py[/blue]
    - [blue]app/app.py[/blue]
    - [blue]app/api.py[/blue]

    It also detects the directory that needs to be added to the [bold]PYTHONPATH[/bold] to make the app importable and adds it.

    It detects the [bold]FastAPI[/bold] app object to use. By default it looks in the module or package for an object named:

    - [blue]app[/blue]
    - [blue]api[/blue]

    Otherwise, it uses the first [bold]FastAPI[/bold] app found in the imported module or package.
    r8   )	r'   r    r!   r"   r#   r$   r%   r(   r&   Nr?   )r'   r    r!   r"   r#   r$   r%   r&   s           r   r8   r8      s(    Z 	#
r   c                      t                y N)r%   r   r   r   mainrC     s    Er   rB   )r   N))loggingr   pathlibr   typingr   r   r   r   r   rich.paddingr   
rich.panelr	   typing_extensionsr
   fastapi_cli.discoverr   fastapi_cli.exceptionsr   r   r   r   Typerr%   __name__r4   r7   ImportErrorboolr   r   Optionr6   intr=   r(   Argumentr-   r8   rC   r   r   r   <module>rS      s           ' 2 6  "ekk6* 	8	
D T   	dDj:EU	
	 
 $ #0  $ 0
d

0 0 	0
 0 390 0 0 
sDy	0 0 
0f  	O 	 	 	 	 	 	WO
dDj D	
	O  T	
	O  d	
	O(  W	
	)O4  w	
	5O@ 
c4i i	
	
AOL w	
	MOX 	YO Od  	V 	 	 	 	 	 	 	cV
dDj D	
	V  T	
	V  d	
	V(  W	
	)V4 c4i\	
	5V@  w	
	AVL 
c4i i	
	
MVX w	
	YVd 	eV Vr
y  Gs   ,J1 1J<;J<