From 6ebfc7d3fb3a54a36fad57845130458b765aa8ce Mon Sep 17 00:00:00 2001 From: Riley Housden Date: Fri, 11 Mar 2022 11:06:55 -0500 Subject: [PATCH] Fix router loading on Windows systems --- api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api.py b/api.py index 1358186..e3d84b9 100644 --- a/api.py +++ b/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 - 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("/")