Skip to content

Commit

Permalink
add assets path
Browse files Browse the repository at this point in the history
  • Loading branch information
optk2k committed Jan 12, 2024
1 parent d1cc02d commit d728528
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions df_designer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ def meta():
def run_app(
ip_address: str = app.conf_host,
port: int = app.conf_port,
dir_logs: str = app.dir_logs,
):
"""Run the application."""
app.dir_logs = dir_logs
config = uvicorn.Config(
app=app.conf_app,
host=ip_address,
Expand Down
7 changes: 7 additions & 0 deletions df_designer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
StaticFiles(directory=app.static_files),
name="static",
)

app.mount(
"/assets",
StaticFiles(directory=app.static_assets),
name="assets",
)

# TODO: добавить версию v1
# TODO: заглушка для dff
# TODO: тесты дописать
Expand Down
4 changes: 2 additions & 2 deletions df_designer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

from fastapi import FastAPI

app = FastAPI()


class Application(FastAPI):
package_dir = Path(__file__).absolute()
static_files = package_dir.with_name("static")
static_assets = static_files.joinpath("assets")
start_page = static_files.joinpath("index.html")
work_directory = "."
path_to_save = Path(work_directory).joinpath("flows.json")
Expand All @@ -17,6 +16,7 @@ class Application(FastAPI):
conf_port = 8000
conf_log_level = "info"
conf_reload = True
dir_logs = "logs"


app = Application()
Empty file.
8 changes: 6 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ def test_settings():
assert app.conf_port == 8000
assert app.conf_log_level == "info"
assert app.conf_reload is True
assert app.dir_logs == "logs"
assert app.static_files == app.package_dir.with_name("static")
assert app.static_assets == app.static_files.joinpath("assets")


# def test_settings_path_to_save():
# assert app.path_to_save == Path(app.work_directory).joinpath("flows.json")
# TODO: test work directory
# TODO: path_to_save
# TODO: test assets path

0 comments on commit d728528

Please sign in to comment.