Spaces:
Sleeping
Sleeping
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -123,11 +123,13 @@ with gr.Blocks() as demo:
|
|
123 |
status_button.click(fn=check_status, outputs=status_output)
|
124 |
send_button.click(fn=send_message_to_discord, inputs=[channel_id_input, message_input], outputs=send_output)
|
125 |
|
126 |
-
# λμ€μ½λ λ΄μ
|
127 |
-
def
|
128 |
-
discord_client
|
|
|
|
|
|
|
|
|
129 |
|
130 |
if __name__ == "__main__":
|
131 |
-
|
132 |
-
threading.Thread(target=run_discord_bot).start() # λ΄ μ€ν
|
133 |
-
demo.launch(server_name="0.0.0.0", server_port=5000) # Gradio μλ² μ€ν
|
|
|
123 |
status_button.click(fn=check_status, outputs=status_output)
|
124 |
send_button.click(fn=send_message_to_discord, inputs=[channel_id_input, message_input], outputs=send_output)
|
125 |
|
126 |
+
# Gradio λ° λμ€μ½λ λ΄μ λΉλκΈ°λ‘ μ€ν
|
127 |
+
async def main():
|
128 |
+
global discord_client
|
129 |
+
discord_client = MyClient(intents=intents)
|
130 |
+
bot_task = asyncio.create_task(discord_client.start(os.getenv('DISCORD_TOKEN')))
|
131 |
+
gradio_task = asyncio.to_thread(demo.launch, server_name="0.0.0.0", server_port=5000)
|
132 |
+
await asyncio.gather(bot_task, gradio_task)
|
133 |
|
134 |
if __name__ == "__main__":
|
135 |
+
asyncio.run(main())
|
|
|
|