forked from dream-aim-deliver/mpi-sda-telegram-scraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
35 lines (24 loc) · 829 Bytes
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
from dotenv import load_dotenv
from fastapi import FastAPI
from app.sdk.job_manager import BaseJobManager
from app.sdk.job_router import JobManagerFastAPIRouter
from telegram_scraper import scrape
import logging
load_dotenv()
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
logger = logging.getLogger(__name__)
HOST = os.getenv("HOST", "localhost")
PORT = int(os.getenv("PORT", "8000"))
MODE = os.getenv("MODE", "production")
app = FastAPI()
app.job_manager = BaseJobManager() # type: ignore
job_manager_router = JobManagerFastAPIRouter(app, scrape)
if __name__ == "__main__":
import uvicorn
print(f"Starting server on {HOST}:{PORT}")
uvicorn.run("server:app", host=HOST, port=PORT, reload=True)