Skip to content

Commit

Permalink
fix main
Browse files Browse the repository at this point in the history
  • Loading branch information
tijsziere committed Oct 22, 2024
1 parent ae050ed commit ab942b6
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,13 @@
import requests
import os
from dotenv import load_dotenv
from utils.logger import logger
from routes import routes121, routesEspo, routesGeneric, routesKobo

# load environment variables
load_dotenv()
port = os.environ["PORT"]

# Set up logs export to Azure Application Insights
logger_provider = LoggerProvider()
set_logger_provider(logger_provider)
exporter = AzureMonitorLogExporter(
connection_string=os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"]
)
logger_provider.add_log_record_processor(BatchLogRecordProcessor(exporter))

# Attach LoggingHandler to root logger
handler = LoggingHandler()
logging.getLogger().addHandler(handler)
logging.getLogger().setLevel(logging.NOTSET)
logger = logging.getLogger(__name__)

# Silence noisy loggers
logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)
logging.getLogger("azure").setLevel(logging.WARNING)
logging.getLogger("requests_oauthlib").setLevel(logging.WARNING)
logging.getLogger("asyncio").setLevel(logging.WARNING)
logging.getLogger("opentelemetry").setLevel(logging.ERROR)

# initialize FastAPI
app = FastAPI(
title="kobo-connect",
Expand All @@ -46,16 +25,6 @@
},
)

# initialize CosmosDB
client_ = cosmos_client.CosmosClient(
os.getenv("COSMOS_URL"),
{"masterKey": os.getenv("COSMOS_KEY")},
user_agent="kobo-connect",
user_agent_overwrite=True,
)
cosmos_db = client_.get_database_client("kobo-connect")
cosmos_container_client = cosmos_db.get_container_client("kobo-submissions")


@app.get("/", include_in_schema=False)
async def docs_redirect():
Expand Down

0 comments on commit ab942b6

Please sign in to comment.