|
67 | 67 | expose_headers=[siibra_version_header]
|
68 | 68 | )
|
69 | 69 |
|
70 |
| - |
71 |
| -_code_meta = None |
72 |
| -@siibra_api.get("/about", include_in_schema=False) |
73 |
| -def servicemeta(): |
74 |
| - global _code_meta |
75 |
| - if _code_meta is None: |
76 |
| - with open(Path(__file__).parent.parent.parent / "codemeta.json", "r") as fp: |
77 |
| - _code_meta = json.load(fp=fp) |
78 |
| - if _code_meta is None: |
79 |
| - raise Exception("code meta is not found, cannot populate servicemeta") |
80 |
| - return { |
81 |
| - "@context": "https://gitlab.ebrains.eu/lauramble/servicemeta/-/raw/main/data/contexts/servicemeta.jsonld", |
82 |
| - "type": "WebApplication", |
83 |
| - "author": _code_meta["author"], |
84 |
| - "dateModified": _code_meta["dateModified"], |
85 |
| - "documentation": DOCUMENTATION_URL, |
86 |
| - "name": _code_meta["name"], |
87 |
| - "version": _code_meta["version"], |
88 |
| - "inputFormat": INPUT_FORMAT, |
89 |
| - "outputFormat": OUTPUT_FORMAT |
90 |
| - } |
91 |
| - |
92 |
| -@siibra_api.get("/", include_in_schema=False) |
93 |
| -def get_home(request: Request): |
94 |
| - """Return the template for the siibra landing page.""" |
95 |
| - return templates.TemplateResponse( |
96 |
| - "index.html", context={ |
97 |
| - "request": request, |
98 |
| - "api_version": __version__, |
99 |
| - "git_hash": GIT_HASH, |
100 |
| - "versions": ["v3_0", "v2_0", "v1_0"] |
101 |
| - }) |
102 |
| - |
103 | 70 | # Each middleware function is called before the request is processed
|
104 | 71 | # For FastAPI the order is important.
|
105 | 72 | # The functions are called (perhaps counter-intuitively) from bottom to top.
|
@@ -377,6 +344,39 @@ async def exception_other(request: Request, exc: Exception):
|
377 | 344 |
|
378 | 345 | # it seems other mounts must be mounted **after** VersionedFastAPI is called
|
379 | 346 | templates = Jinja2Templates(directory="templates/")
|
| 347 | + |
| 348 | +_code_meta = None |
| 349 | +@siibra_api.get("/about", include_in_schema=False) |
| 350 | +def servicemeta(): |
| 351 | + global _code_meta |
| 352 | + if _code_meta is None: |
| 353 | + with open(Path(__file__).parent.parent.parent / "codemeta.json", "r") as fp: |
| 354 | + _code_meta = json.load(fp=fp) |
| 355 | + if _code_meta is None: |
| 356 | + raise Exception("code meta is not found, cannot populate servicemeta") |
| 357 | + return { |
| 358 | + "@context": "https://gitlab.ebrains.eu/lauramble/servicemeta/-/raw/main/data/contexts/servicemeta.jsonld", |
| 359 | + "type": "WebApplication", |
| 360 | + "author": _code_meta["author"], |
| 361 | + "dateModified": _code_meta["dateModified"], |
| 362 | + "documentation": DOCUMENTATION_URL, |
| 363 | + "name": _code_meta["name"], |
| 364 | + "version": _code_meta["version"], |
| 365 | + "inputFormat": INPUT_FORMAT, |
| 366 | + "outputFormat": OUTPUT_FORMAT |
| 367 | + } |
| 368 | + |
| 369 | +@siibra_api.get("/", include_in_schema=False) |
| 370 | +def get_home(request: Request): |
| 371 | + """Return the template for the siibra landing page.""" |
| 372 | + return templates.TemplateResponse( |
| 373 | + "index.html", context={ |
| 374 | + "request": request, |
| 375 | + "api_version": __version__, |
| 376 | + "git_hash": GIT_HASH, |
| 377 | + "versions": ["v3_0", "v2_0", "v1_0"] |
| 378 | + }) |
| 379 | + |
380 | 380 | siibra_api.mount("/static", StaticFiles(directory="static"), name="static")
|
381 | 381 |
|
382 | 382 | @siibra_api.get("/metrics", include_in_schema=False)
|
|
0 commit comments