import gradio as gr import hashlib # Simulated user database (in a real app, this would be a secure database) users = { "admin": "8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918", # password: admin "user": "04f8996da763b7a969b1028ee3007569eaf3a635486ddab211d512c85b9df8fb", # password: user } def hash_password(password): return hashlib.sha256(password.encode()).hexdigest() def login(username, password): if username in users and users[username] == hash_password(password): return f"Welcome, {username}!" else: return "Invalid username or password." # Create the Gradio interface iface = gr.Interface( fn=login, inputs=[ gr.Textbox(label="Username"), gr.Textbox(label="Password", type="password") ], outputs=gr.Textbox(label="Result"), title="Login App", description="Enter your username and password to log in." ) # Launch the app if __name__ == "__main__": iface.launch()