-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
42 lines (35 loc) · 1.02 KB
/
main.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
36
37
38
39
40
41
42
# Dotenv if available
print("INFO: Loading dotenv if available")
from dotenv import load_dotenv
load_dotenv()
# Init Deep Learning Models
print("INFO: Load Models Deep Learning Models")
from modules.models import model
print("INFO: Deep Learning Models Loaded")
# Init Database
print("INFO: Testing Database")
from modules.database import db
# Init Redis
print("INFO: Connecting to Redis")
from modules.redis import redis
if not redis.ping():
print("ERROR: Cannot connect to REDIS")
exit(1)
print("INFO: Redis connected ")
# Scheduling for Database Caching
print("INFO: Loading scheduler")
from apscheduler.schedulers.background import BackgroundScheduler
scheduler = BackgroundScheduler()
scheduler.add_job(db.cache_database, 'interval', minutes=2)
scheduler.start()
# Init API
import uvicorn
from fastapi import FastAPI
api = FastAPI()
# Include API
from modules.api import api_router
api.include_router(api_router)
# Init Endpoint
port = 8001
print(f"Listening to http://0.0.0.0:{port}")
uvicorn.run(api, host='0.0.0.0',port=port)