import os import gradio as gr from pymongo import MongoClient access_token = os.environ.get('HF_TOKEN') ui = gr.load("sun000090/gradio_space", hf_token=access_token, src="spaces") ### Fetch MongoDB Authentication uri = os.environ.get('MONGODB_URI') client = MongoClient(uri, connect=True) db = client['LoginDetails'] userLogin = db['LoginDetails'] def check_credentials(email, password): user = userLogin.find_one({'email': email}) if not user or user['password'] != password: return 'Incorrect' return 'Correct' ### Authenticate through space def environ_auth(username, password): auth_ = check_credentials(username, password) if auth_=='Correct': return True else: return False ui.launch(share=True, auth=environ_auth, show_api=False)