Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions modal_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,27 @@ def manifest(manifest: dict):
return manifest


@app.function(volumes={"/data": vol})
@modal.fastapi_endpoint()
@app.function(volumes={"/data": vol}, min_containers=1)
@modal.asgi_app()
def dashboard():
import json
from pathlib import Path

vol.reload()

manifest_path = Path("/data")
manifest_files = manifest_path.glob("*.json")
manifests = []
for mf in manifest_files:
with open(mf, "r") as f:
manifests.append(json.load(f))

return {"manifests": manifests}
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

web_app = FastAPI()
web_app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["GET"],
allow_headers=["*"],
)

@web_app.get("/")
def get_manifests():
import json
from pathlib import Path

vol.reload()
manifests = [json.loads(p.read_text()) for p in Path("/data").glob("*.json")]
return {"manifests": manifests}

return web_app
Loading