Skip to content

Commit 25309cb

Browse files
committed
reduce startup complicity.
1 parent 8187ed9 commit 25309cb

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ To achieve this, when users submit a message to the web server, the web server w
5858
5. Start the services with this command:
5959

6060
```shell
61-
cd src
62-
python -m uvicorn "api.main:create_app" --port 50505 --reload
61+
python -m uvicorn "api.main:create_app" --app-dir src --port 50505 --reload
6362
```
6463

6564
6. Click 'http://localhost:50505' in the browser to run the application.

src/api/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ def create_app():
102102
logger.info("Loading .env file")
103103
load_dotenv(override=True)
104104

105+
directory = os.path.join(os.path.dirname(__file__), "static")
105106
app = fastapi.FastAPI(lifespan=lifespan)
106-
app.mount("/static", StaticFiles(directory="api/static"), name="static")
107+
app.mount("/static", StaticFiles(directory=directory), name="static")
107108

108109
from . import routes # noqa
109110

src/api/routes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727

2828
router = fastapi.APIRouter()
29-
templates = Jinja2Templates(directory="api/templates")
29+
directory = os.path.join(os.path.dirname(__file__), "templates")
30+
templates = Jinja2Templates(directory=directory)
3031

3132

3233

0 commit comments

Comments
 (0)