Fix router loading on Windows systems
This commit is contained in:
parent
6cdbdefd54
commit
6ebfc7d3fb
1 changed files with 5 additions and 1 deletions
4
api.py
4
api.py
|
@ -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
|
||||
if platform.system() != "Windows":
|
||||
load_module(str(m_path).replace("/", ".").replace(".py", ""))
|
||||
else:
|
||||
load_module(str(m_path).replace("\\", ".").replace(".py", ""))
|
||||
|
||||
|
||||
@api.get("/")
|
||||
|
|
Loading…
Reference in a new issue