
    U[is                     L    d e de fdZedk(  rddlZ ej                  e       yy)url_or_space_idsource_directoryc                 @  	
 dd l ddlm} ddlm} ddlm} ddlmm		  |      
 |d      } ||       r| j                  d      nd ||       j                   d	|j                         d
t        dt        f	
fd       }|j                  d       y )N    )is_http_url_like)
space_info)FastMCP)abspathis_in_or_equalz
upload-mcp/zhttps://z	.hf.spacefilereturnc                     |       } |      st        d|  d       t        |d      5 }j                  	 dd|i      }ddd       j                          |j	                         d   }	 d	| S # 1 sw Y   3xY w)
a  Generate a Gradio File Input for a local file by uploading it to a Gradio app and returning the URL.
        Arguments:
            file: A complete, absolute path to a local file to upload.
        Returns:
            Gradio File Input - A URL to the uploaded file.
        zFile z is not in rbz/gradio_api/uploadfiles)r   Nr   z/gradio_api/file=)
ValueErroropenpostraise_for_statusjson)
r   target_pathfresponseresultr	   httpxr
   source_pathurls
        l/var/www/html/chatbot/Makanify-Chatbot-3/venv/lib/python3.12/site-packages/gradio/cli/commands/upload_mcp.pyupload_file_to_gradioz#main.<locals>.upload_file_to_gradio   s     dmk;7uTF+k]CDD+t$ 	RzzSE);"<WaLzQH	R!!##'x00		R 	Rs   A;;Bstdio)	transport)r   gradio_client.utilsr   huggingface_hubr   mcp.server.fastmcpr   gradio.utilsr	   r
   rstrip	subdomaintoolstrrun)r   r   r   r   r   mcpr   r	   r   r
   r   r   s          @@@@@r   mainr+      s    4**4*+K
,
C($$S)O4>>?yIXXZ1C 1C 1 1 1& GGgG    __main__r   N)r(   r+   __name__typerr)    r,   r   <module>r1      s8   %# % %P zEIIdO r,   