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

Clinical-Genomics / genotype-api / 8169178037

06 Mar 2024 08:39AM UTC coverage: 0.106%. First build
8169178037

Pull #79

github

henrikstranneheim
Merge branch 'main' into add-black

# Conflicts:
#	requirements.txt
Pull Request #79: feat(black)

1 of 940 relevant lines covered (0.11%)

0.0 hits per line

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

0.0
/genotype_api/api/app.py
1
"""
2
Main functions for the genotype api
3

4
"""
5

6
from fastapi import FastAPI, status, Request
×
7
from fastapi.responses import JSONResponse
×
8
from fastapi.middleware.cors import CORSMiddleware
×
9

10
from genotype_api.config import security_settings
×
11
from genotype_api.database import create_db_and_tables
×
12
from genotype_api.api.endpoints import samples, snps, users, plates, analyses
×
13
from sqlalchemy.exc import NoResultFound
×
14

15
app = FastAPI(
×
16
    root_path=security_settings.api_root_path,
17
    root_path_in_servers=True,
18
    openapi_prefix=security_settings.api_root_path,
19
)
20
app.add_middleware(
×
21
    CORSMiddleware,
22
    allow_origins=["*"],
23
    allow_credentials=True,
24
    allow_methods=["*"],
25
    allow_headers=["*"],
26
)
27

28

29
@app.exception_handler(NoResultFound)
×
30
async def not_found_exception_handler(request: Request, exc: NoResultFound):
×
31
    return JSONResponse("Document not found", status_code=status.HTTP_404_NOT_FOUND)
×
32

33

34
@app.get("/")
×
35
def welcome():
×
36
    return {"hello": "Welcome to the genotype api"}
×
37

38

39
app.include_router(
×
40
    users.router,
41
    prefix="/users",
42
    tags=["users"],
43
    responses={status.HTTP_404_NOT_FOUND: {"description": "Not found"}},
44
)
45

46
app.include_router(
×
47
    samples.router,
48
    prefix="/samples",
49
    tags=["samples"],
50
    responses={status.HTTP_404_NOT_FOUND: {"description": "Not found"}},
51
)
52

53
app.include_router(
×
54
    plates.router,
55
    prefix="/plates",
56
    tags=["plates"],
57
    responses={status.HTTP_404_NOT_FOUND: {"description": "Not found"}},
58
)
59

60
app.include_router(
×
61
    snps.router,
62
    prefix="/snps",
63
    tags=["snps"],
64
    responses={status.HTTP_404_NOT_FOUND: {"description": "Not found"}},
65
)
66

67
app.include_router(
×
68
    analyses.router,
69
    prefix="/analyses",
70
    tags=["analyses"],
71
    responses={status.HTTP_404_NOT_FOUND: {"description": "Not found"}},
72
)
73

74

75
@app.on_event("startup")
×
76
def on_startup():
×
77
    create_db_and_tables()
×
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