imagen3 / app.py
artintel235's picture
Create app.py
e0fa04b verified
raw
history blame
993 Bytes
import discord
from discord import app_commands
import os
import requests
import asyncio
import aiohttp # Use aiohttp for asynchronous HTTP requests
import gradio as gr # Import Gradio
# --- Environment Variables & Setup ---
DISCORD_BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN")
# --- Discord Bot Setup ---
intents = discord.Intents.default()
client = discord.Client(intents=intents)
tree = app_commands.CommandTree(client)
# --- Gradio Interface ---
def echo_text(text):
return text
def run_gradio():
gr.Interface(
fn=echo_text,
inputs="text",
outputs="text",
live=False,
title="Minimal Gradio Interface",
).launch(server_name="0.0.0.0", server_port=7860, share=False, show_error=True)
async def main():
bot_task = asyncio.create_task(client.start(DISCORD_BOT_TOKEN))
gradio_task = asyncio.to_thread(run_gradio)
await asyncio.gather(bot_task, gradio_task)
if __name__ == "__main__":
asyncio.run(main())