nvd commited on
Commit
9dd7b27
·
verified ·
1 Parent(s): 55ba68e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -7,19 +7,30 @@ from bot import start_bot
7
  logging.basicConfig(level=logging.INFO)
8
  logger = logging.getLogger(__name__)
9
 
 
10
  status = gr.Textbox(value="🟡 Starting...", label="Bot Status", interactive=False)
11
 
 
 
 
12
  async def main():
 
13
  asyncio.create_task(start_bot(status_callback=lambda msg: logger.info(msg)))
 
 
14
 
 
15
  with gr.Blocks() as demo:
16
  gr.Markdown("# 🤖 GitHub Release Bot for Bale")
17
  status.render()
18
 
19
  demo.queue()
 
20
  demo.launch(prevent_thread_lock=True)
21
 
 
22
  try:
23
  asyncio.get_event_loop().run_until_complete(main())
24
  except RuntimeError:
 
25
  asyncio.create_task(main())
 
7
  logging.basicConfig(level=logging.INFO)
8
  logger = logging.getLogger(__name__)
9
 
10
+ # A placeholder to show status (for debugging)
11
  status = gr.Textbox(value="🟡 Starting...", label="Bot Status", interactive=False)
12
 
13
+ def update_status(message):
14
+ return message
15
+
16
  async def main():
17
+ # Start the bot in the background
18
  asyncio.create_task(start_bot(status_callback=lambda msg: logger.info(msg)))
19
+ # We can't easily update the Gradio interface from a separate thread,
20
+ # but the bot will run regardless. The startup log will appear in Space's logs.
21
 
22
+ # Build the Gradio interface
23
  with gr.Blocks() as demo:
24
  gr.Markdown("# 🤖 GitHub Release Bot for Bale")
25
  status.render()
26
 
27
  demo.queue()
28
+ # Launch the web interface, but do not block the event loop
29
  demo.launch(prevent_thread_lock=True)
30
 
31
+ # Now start the bot
32
  try:
33
  asyncio.get_event_loop().run_until_complete(main())
34
  except RuntimeError:
35
+ # If already running (e.g., in some environments)
36
  asyncio.create_task(main())