File size: 793 Bytes
09793cc ccad6fc 09793cc e536769 ccad6fc e536769 33a985a e536769 09793cc e536769 33a985a 09793cc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
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) |