U
    nd[                     @   s  d dl 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 e  eje jdd	d
d ejddddd eddddZddgZejeeddgdgd ejdedddd eddd Zejd d!gd"d#d$d% Zee dS )&    N)logger)FastAPI)StaticFiles)RedirectResponse)CORSMiddleware)routerTz9<green>{time:HH:mm:ss}</green> | <level>{message}</level>
   )Zcolorizeformatlevelzbased_content_advertising.logz1 MBDEBUGzip)Zrotationr
   compressionzBased Content Advertising APIzDThis is a Project for content advertising based on video processing.z0.0.1)titledescriptionversionzhttp://localhost:2023zhttp://173.212.199.208:2023*)Zallow_originsZallow_credentialsZallow_methodsZallow_headersz/staticZstatic)	directory)namestartupc               	   C   s.   t  } tdd}t| | W 5 Q R X dS )z\
    Event handler that saves the OpenAPI documentation data to a JSON file on startup.
    zopenapi.jsonwN)appZopenapiopenjsondump)Zopenapi_datafile r   !/var/www/html/BCA_API/app/main.pysave_openapi_json/   s    r   /ZRootF)ZtagsZinclude_in_schemac                      s   t d tddS )z
    Redirects the root URL ("/") to the API documentation page.

    Returns:
        RedirectResponse: Redirects the client to the "/docs" endpoint.
    zRedirecting root URL to /docsz/docs)url)r   debugr   r   r   r   r   root9   s    
r!   )sysr   Zlogurur   Zfastapir   Zfastapi.staticfilesr   Zfastapi.responsesr   Zfastapi.middleware.corsr   Zapp.apir   removeaddstderrr   originsZadd_middlewareZmountZon_eventr   getr!   Zinclude_routerr   r   r   r   <module>   sH   	
	

