new-space / app.py
yamanju's picture
initial commit
af49474 verified
import gradio as gr
import os
from azure.storage.blob import BlobServiceClient
from azure.identity import DefaultAzureCredential
class AzureGradioApp:
def __init__(self):
self.blob_service = BlobServiceClient(
account_url="your_storage_account_url",
credential=DefaultAzureCredential()
)
self.container = self.blob_service.get_container_client("png-container")
def handle_login(self, username, password):
if username == "admin" and password == "dashboard":
return "Login successful"
return "Invalid credentials"
def search_isrc(self, isrc):
try:
blob_url = f"{self.blob_service.url}/{isrc}.png"
return blob_url
except:
return None
def build_ui(self):
with gr.Blocks(theme=gr.themes.Soft()) as interface:
gr.Markdown("# ARTIFICIAL STREAMING DASHBOARD")
with gr.Tab("Login"):
username = gr.Textbox(label="Username")
password = gr.Textbox(label="Password", type="password")
login_btn = gr.Button("Login")
login_output = gr.Textbox(label="Status")
login_btn.click(self.handle_login, [username, password], login_output)
with gr.Tab("Search"):
isrc_input = gr.Textbox(label="ISRC Code")
search_btn = gr.Button("Search")
image_output = gr.Image(label="Graph")
search_btn.click(self.search_isrc, isrc_input, image_output)
with gr.Tab("Top 5"):
query_btn = gr.Button("Query Top 5")
gallery = gr.Gallery(label="Top 5 ISRCs")
return interface
if __name__ == "__main__":
app = AzureGradioApp()
interface = app.build_ui()
interface.launch(share=True)