• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ggravlingen / pypmanager / 16147492242

08 Jul 2025 03:24PM UTC coverage: 94.34% (-0.03%) from 94.374%
16147492242

push

github

web-flow
Add debug information (#1594)

121 of 127 branches covered (95.28%)

Branch coverage included in aggregate %.

1379 of 1463 relevant lines covered (94.26%)

0.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.37
pypmanager/api/server.py
1
"""FastAPI server."""
2

3
from __future__ import annotations
1✔
4

5
from collections.abc import AsyncGenerator, Awaitable, Callable
1✔
6
from contextlib import asynccontextmanager
1✔
7
import logging
1✔
8
from typing import cast
1✔
9

10
from fastapi import FastAPI, Request, Response
1✔
11
from fastapi.responses import FileResponse, HTMLResponse
1✔
12
from fastapi.staticfiles import StaticFiles
1✔
13

14
from pypmanager.database.helpers import sync_security_files_to_db
1✔
15
from pypmanager.settings import APP_DATA, APP_FRONTEND, APP_ROOT, Settings
1✔
16

17
from .graphql import graphql_app
1✔
18
from .scheduler import scheduler
1✔
19

20
_LOGGER = logging.getLogger("pypmanager.startup")
1✔
21

22

23
@asynccontextmanager
1✔
24
async def async_lifespan(_: FastAPI) -> AsyncGenerator[None]:
1✔
25
    """Start and shutdown the scheduler."""
26
    for folder, name in [
1✔
27
        (APP_ROOT, "App folder"),
28
        (APP_DATA, "User data folder"),
29
        (APP_FRONTEND, "Frontend folder"),
30
    ]:
31
        if folder.exists():
1✔
32
            _LOGGER.info(f"{name} exists at {folder}")
1✔
33
        else:
34
            _LOGGER.info(f"{name} is missing at {folder}")
×
35

36
    scheduler.start()
1✔
37
    await sync_security_files_to_db()
1✔
38
    yield
1✔
39
    scheduler.shutdown()
1✔
40

41

42
app = FastAPI(lifespan=async_lifespan)
1✔
43

44
TypeGraphQL = Callable[[Request], Awaitable[Response] | Response]
1✔
45

46
app.add_route("/graphql", cast("TypeGraphQL", graphql_app))
1✔
47

48
app.mount("/static", StaticFiles(directory=Settings.dir_static), name="static")
1✔
49

50

51
@app.get("/favicon.ico")
1✔
52
async def get_favicon() -> FileResponse:
1✔
53
    """Return favicon."""
54
    return FileResponse(f"{Settings.dir_static}/favicon.ico")
1✔
55

56

57
@app.get("/status")
1✔
58
def get_index() -> HTMLResponse:
1✔
59
    """Return status OK."""
60
    return HTMLResponse(content="OK")
1✔
61

62

63
@app.get("/", response_class=FileResponse)
1✔
64
async def index_page() -> FileResponse:
1✔
65
    """Return the index page."""
66
    return FileResponse(f"{Settings.dir_templates}/index.html")
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc