diff --git a/migas_server/app.py b/migas_server/app.py index 93c0cf0..ad45c3f 100644 --- a/migas_server/app.py +++ b/migas_server/app.py @@ -1,6 +1,8 @@ import os +from pkg_resources import resource_filename from fastapi import FastAPI +from fastapi.responses import FileResponse from fastapi.middleware.cors import CORSMiddleware from strawberry.fastapi import GraphQLRouter @@ -57,10 +59,15 @@ async def shutdown(): await app.requests.close() -@app.get("/") -async def root(): +@app.get("/info") +async def info(): return { "package": "migas", "version": __version__, "message": "Visit /graphql for GraphiQL interface", } + +@app.get("/") +async def home(): + index = resource_filename("migas_server", "frontend/index.html") + return FileResponse(index) diff --git a/migas_server/frontend/index.html b/migas_server/frontend/index.html new file mode 100644 index 0000000..e514791 --- /dev/null +++ b/migas_server/frontend/index.html @@ -0,0 +1,11 @@ + + +
+ + +Migas collects anonymized usage information across projects.
+ + diff --git a/migas_server/tests/test_server.py b/migas_server/tests/test_server.py index 449adc2..db962cc 100644 --- a/migas_server/tests/test_server.py +++ b/migas_server/tests/test_server.py @@ -32,9 +32,15 @@ def client(event_loop: asyncio.BaseEventLoop) -> Iterator[TestClient]: yield c -def test_server_startup_shutdown(client: TestClient) -> None: +def test_server_landing(client: TestClient) -> None: res = client.get("/") assert res.status_code == 200 + assert 'html' in res.headers.get("Content-Type") + + +def test_server_info(client: TestClient) -> None: + res = client.get("/info") + assert res.status_code == 200 assert res.json()["package"] == "migas"