davanstrien HF staff commited on
Commit
665f955
1 Parent(s): cb643a9

chore: Update main.py imports and add root endpoint

Browse files
Files changed (1) hide show
  1. main.py +12 -4
main.py CHANGED
@@ -1,11 +1,14 @@
1
- from typing import Optional, List
2
  from contextlib import asynccontextmanager
 
 
 
 
3
  from fastapi import FastAPI, HTTPException, Query
4
  from pydantic import BaseModel
5
- import chromadb
6
- import logging
7
  from load_data import get_save_path, refresh_data
8
- from cashews import cache
9
 
10
  # Set up logging
11
  logging.basicConfig(
@@ -51,6 +54,11 @@ async def lifespan(app: FastAPI):
51
  app = FastAPI(lifespan=lifespan)
52
 
53
 
 
 
 
 
 
54
  @app.get("/query", response_model=Optional[QueryResponse])
55
  @cache(ttl="1h")
56
  async def api_query_dataset(dataset_id: str, n: int = Query(default=10, ge=1, le=100)):
 
1
+ import logging
2
  from contextlib import asynccontextmanager
3
+ from typing import List, Optional
4
+
5
+ import chromadb
6
+ from cashews import cache
7
  from fastapi import FastAPI, HTTPException, Query
8
  from pydantic import BaseModel
9
+ from starlette.responses import RedirectResponse
10
+
11
  from load_data import get_save_path, refresh_data
 
12
 
13
  # Set up logging
14
  logging.basicConfig(
 
54
  app = FastAPI(lifespan=lifespan)
55
 
56
 
57
+ @app.get("/", include_in_schema=False)
58
+ def root():
59
+ return RedirectResponse(url="/docs")
60
+
61
+
62
  @app.get("/query", response_model=Optional[QueryResponse])
63
  @cache(ttl="1h")
64
  async def api_query_dataset(dataset_id: str, n: int = Query(default=10, ge=1, le=100)):