Fix router loading on Windows systems

This commit is contained in:
Riley Housden 2022-03-11 11:06:55 -05:00
parent 6cdbdefd54
commit 6ebfc7d3fb
Signed by: InValidFire
GPG key ID: 0D6208F6DF56B4D8

6
api.py
View file

@ -1,5 +1,6 @@
import importlib
import logging
import platform
from pathlib import Path
from fastapi import FastAPI
@ -19,7 +20,10 @@ def load_module(name: str):
for m_path in Path("routers").glob("*"):
if "__pycache__" in m_path.parts or "__init__" == m_path.stem:
continue
load_module(str(m_path).replace("/", ".").replace(".py", ""))
if platform.system() != "Windows":
load_module(str(m_path).replace("/", ".").replace(".py", ""))
else:
load_module(str(m_path).replace("\\", ".").replace(".py", ""))
@api.get("/")