|
|
import gradio as gr |
|
|
|
|
|
|
|
|
|
|
|
users_db = { |
|
|
"jsmith": { |
|
|
"username": "jsmith", |
|
|
"email": "john.smith@company.com", |
|
|
"name": "John Smith", |
|
|
"user_id": "US789456", |
|
|
"jobtitle": "Software Engineer", |
|
|
"department": "Engineering", |
|
|
"country": "United States", |
|
|
}, |
|
|
"mhacker": { |
|
|
"username": "mhacker", |
|
|
"email": "maria.hacker@company.com", |
|
|
"name": "Maria Hacker", |
|
|
"user_id": "US123789", |
|
|
"jobtitle": "Security Specialist", |
|
|
"department": "Pentests", |
|
|
"country": "Germany", |
|
|
}, |
|
|
} |
|
|
|
|
|
|
|
|
def lookup_user(username: str) -> str: |
|
|
"""Function to lookup user information. |
|
|
|
|
|
Company User Lookup System. Enter a username to get user details. |
|
|
|
|
|
Returns: |
|
|
A formatted string with user details if found, otherwise an |
|
|
error message. |
|
|
""" |
|
|
if username in users_db: |
|
|
user = users_db[username] |
|
|
return f"""User Information: |
|
|
Username: {user['username']} |
|
|
Email: {user['email']} |
|
|
Name: {user['name']} |
|
|
User ID: {user['user_id']} |
|
|
Job Title: {user['jobtitle']} |
|
|
Department: {user['department']} |
|
|
Country: {user['country']}""" |
|
|
|
|
|
return """User Not Found |
|
|
Username: Not found |
|
|
Email: N/A |
|
|
Name: N/A |
|
|
User ID: N/A |
|
|
Job Title: N/A |
|
|
Department: N/A |
|
|
Country: N/A""" |
|
|
|
|
|
|
|
|
|
|
|
gr_internal_company = gr.Interface( |
|
|
fn=lookup_user, |
|
|
inputs=["text"], |
|
|
outputs=["text"], |
|
|
title="Company User Lookup System", |
|
|
description="Company User Lookup System.", |
|
|
theme="default", |
|
|
) |
|
|
|