Dmitry Beresnev commited on
Commit
3c6f046
·
1 Parent(s): 558806d
Files changed (2) hide show
  1. main.py +8 -0
  2. src/tg_bot.py +15 -0
main.py CHANGED
@@ -6,6 +6,7 @@ if __name__ == "__main__":
6
  telegram_bot()
7
  '''
8
 
 
9
  from fastapi import FastAPI
10
  import uvicorn
11
 
@@ -14,4 +15,11 @@ app = FastAPI()
14
  @app.get("/")
15
  def read_root():
16
  return {"Hello": "World"}
 
 
17
 
 
 
 
 
 
 
6
  telegram_bot()
7
  '''
8
 
9
+ '''
10
  from fastapi import FastAPI
11
  import uvicorn
12
 
 
15
  @app.get("/")
16
  def read_root():
17
  return {"Hello": "World"}
18
+ '''
19
+
20
 
21
+ from src.tg_bot import main as tgbot
22
+
23
+
24
+ if __name__ == "__main__":
25
+ tgbot()
src/tg_bot.py CHANGED
@@ -310,6 +310,21 @@ async def test_message(chat_id: int, message: str = "Hello World!"):
310
  raise HTTPException(status_code=500, detail=str(e))
311
 
312
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  # Development server
314
  if __name__ == "__main__":
315
  logger.info(f"Starting Financial News Bot on port {Config.PORT}")
 
310
  raise HTTPException(status_code=500, detail=str(e))
311
 
312
 
313
+ def main() -> None:
314
+ """Main entry point for the FastAPI app"""
315
+ if not Config.validate():
316
+ logger.error("Invalid configuration. Exiting...")
317
+ return
318
+
319
+ logger.info(f"Starting Financial News Bot on port {Config.PORT}")
320
+ uvicorn.run(
321
+ app,
322
+ host="0.0.0.0",
323
+ port=Config.PORT,
324
+ log_level="info"
325
+ )
326
+
327
+
328
  # Development server
329
  if __name__ == "__main__":
330
  logger.info(f"Starting Financial News Bot on port {Config.PORT}")