From e29917fbca5c50c7afe8d64977b11b6d4bf59ccd Mon Sep 17 00:00:00 2001 From: shadowik Date: Sun, 20 Oct 2024 15:48:17 +0400 Subject: [PATCH] Fix build application from terminal --- server/README.md | 11 ++++++++--- server/src/data/repository.py | 6 +++--- server/src/main.py | 2 ++ server/src/routers/floris_router.py | 7 +++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/server/README.md b/server/README.md index 5e79c49..f69b485 100644 --- a/server/README.md +++ b/server/README.md @@ -20,8 +20,13 @@ ```zsh pip install -r requirements.txt ``` - -4. Start FastAPI process + +4. Enter src directory ```zsh - fastapi dev main.py + cd src + ``` + +5. Start FastAPI process + ```zsh + uvicorn main:app --reload ``` \ No newline at end of file diff --git a/server/src/data/repository.py b/server/src/data/repository.py index 2411229..b9fbc39 100644 --- a/server/src/data/repository.py +++ b/server/src/data/repository.py @@ -1,8 +1,8 @@ from sqlalchemy import select -from .database import session_maker -from .models import Weather -from .schemas import SWeatherInfo +from data.database import session_maker +from data.models import Weather +from data.schemas import SWeatherInfo class WeatherRepository: diff --git a/server/src/main.py b/server/src/main.py index a535ffc..a4a7788 100644 --- a/server/src/main.py +++ b/server/src/main.py @@ -1,3 +1,5 @@ +import sys + from pathlib import Path from fastapi import FastAPI diff --git a/server/src/routers/floris_router.py b/server/src/routers/floris_router.py index 4e6a260..7bbca30 100644 --- a/server/src/routers/floris_router.py +++ b/server/src/routers/floris_router.py @@ -1,3 +1,4 @@ +import sys from http import HTTPStatus from pathlib import Path from typing import Annotated @@ -8,9 +9,11 @@ from fastapi.responses import FileResponse from data.repository import WeatherRepository from data.schemas import SFlorisInputParams, SFlorisOutputData, SWeatherInfo -from FlorisULSTU import FlorisULSTU -FLORIS_IMAGES_PATH = Path("public/floris") +sys.path.append(str(Path(__file__).parent.parent.parent)) +from floris_module.src import FlorisULSTU + +FLORIS_IMAGES_PATH = Path(__file__).parent.parent.parent / "public" / "floris" router = APIRouter( prefix="/api/floris",