| #!/usr/bin/env python | |
| import os | |
| import gradio as gr | |
| from app import demo as main_demo | |
| allowed_usernames = os.environ["ALLOWED_USERNAMES"].split(",") | |
| def render(profile: gr.OAuthProfile | None) -> dict: | |
| if profile is None: | |
| visible = None | |
| else: | |
| visible = profile.username in allowed_usernames | |
| return gr.Column(visible=visible) | |
| with gr.Blocks() as demo: | |
| gr.LoginButton() | |
| with gr.Column(visible=False) as col: | |
| main_demo.render() | |
| demo.load(fn=render, outputs=col) | |
| if __name__ == "__main__": | |
| demo.launch(show_api=False) | |