omar1232 commited on
Commit
431b370
·
verified ·
1 Parent(s): affb65c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -4,25 +4,23 @@ from telegram import Update
4
  from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
5
 
6
  # ====== Telegram Bot Setup ======
7
- TELEGRAM_TOKEN = "8030235633:AAHKvxM9Nzp0DkxfdotMux3572tC_5CGEUA" # Replace this with your real bot token
8
 
9
- # Simple Telegram command handler
10
  async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
11
  await update.message.reply_text("Hello! I'm your bot!")
12
 
13
  # ====== Gradio App Setup ======
14
-
15
  def greet(name):
16
  return f"Hello, {name}!"
17
 
18
  demo = gr.Interface(fn=greet, inputs="text", outputs="text")
19
 
20
- # Function to run Gradio (no SSR or share=True needed on Hugging Face Spaces)
21
  def run_gradio():
22
- demo.launch(ssr=False) # SSR disabled, share not needed on Spaces
23
 
24
  # ====== Start Both Gradio & Telegram Bot ======
25
-
26
  if __name__ == "__main__":
27
  # Start Gradio in a separate thread
28
  gradio_thread = threading.Thread(target=run_gradio)
 
4
  from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
5
 
6
  # ====== Telegram Bot Setup ======
7
+ TELEGRAM_TOKEN = "8030235633:AAHKvxM9Nzp0DkxfdotMux3572tC_5CGEUAE" # Replace this with your real bot token
8
 
9
+ # Telegram command handler
10
  async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
11
  await update.message.reply_text("Hello! I'm your bot!")
12
 
13
  # ====== Gradio App Setup ======
 
14
  def greet(name):
15
  return f"Hello, {name}!"
16
 
17
  demo = gr.Interface(fn=greet, inputs="text", outputs="text")
18
 
19
+ # Function to run Gradio (no SSR or share needed on Spaces)
20
  def run_gradio():
21
+ demo.launch() # No SSR or share argument needed
22
 
23
  # ====== Start Both Gradio & Telegram Bot ======
 
24
  if __name__ == "__main__":
25
  # Start Gradio in a separate thread
26
  gradio_thread = threading.Thread(target=run_gradio)