meilisearch fastapi
v0.20.0
Meilisearch FastAPI는 Meilisearch와 상호 작용하기 위한 FastAPI 경로를 제공합니다.
이 패키지를 설치하려면 가상 환경을 사용하는 것이 좋습니다. 가상 환경이 생성되고 활성화되면 다음을 사용하여 패키지를 설치하십시오.
pip install meilisearch-fastapi
경로는 그룹으로 분할되어 다양한 종속성을 주입할 수 있으므로 다양한 경로 그룹에 다양한 액세스 수준을 부여할 수 있습니다.
from fastapi import APIRouter , FastAPI
from meilisearch_fastapi . routes import (
document_routes ,
index_routes ,
meilisearch_routes ,
search_routes ,
settings_routes ,
)
app = FastAPI ()
api_router = APIRouter ()
api_router . include_router ( document_routes . router , prefix = "/documents" )
api_router . include_router ( index_routes . router , prefix = "/indexes" )
api_router . include_router ( meilisearch_routes . router , prefix = "/meilisearch" )
api_router . include_router ( search_routes . router , prefix = "/search" )
api_router . include_router ( settings_routes . router , prefix = "/settings" )
app . include_router ( api_router )
from fastapi import APIRouter , FastAPI
from meilisearch_fastapi . routes import (
document_routes ,
index_routes ,
meilisearch_routes ,
search_routes ,
settings_routes ,
)
from my_app import my_authentication
app = FastAPI ()
api_router = APIRouter ()
api_router . include_router ( document_routes . router , prefix = "/documents" , dependeincies = [ Depends ( my_authentication )])
api_router . include_router ( index_routes . router , prefix = "/indexes" , dependeincies = [ Depends ( my_authentication )])
api_router . include_router ( meilisearch_routes . router , prefix = "/meilisearch" , dependeincies = [ Depends ( my_authentication )])
api_router . include_router ( search_routes . router , prefix = "/search" , dependeincies = [ Depends ( my_authentication )])
api_router . include_router ( settings_routes . router , prefix = "/settings" , dependeincies = [ Depends ( my_authentication )])
app . include_router ( api_router )
Meilisearch의 URL, 날씨는 https 주소를 사용해야 하며, API 키는 환경 변수에서 읽어옵니다. 이를 .env 파일에 넣으면 터미널을 다시 시작할 때마다 이러한 변수를 설정하지 않아도 됩니다.
MEILI_HTTP_ADDR=localhost:7700 # This is the url for your instance of Meilisearch
MEILI_HTTPS_URL=true # Setting this specifies the address should be https://. If false or not included the address will be http://
MEILI_MASTER_KEY=masterKey # This is the API key for your Meilisearch instance
이제 FastAPI 앱에서 Meilisearch 경로를 사용할 수 있습니다. 경로에 대한 문서는 FastAPI 앱의 OpenAPI 문서에서 볼 수 있습니다. 이를 보려면 FastAPI 앱을 시작하고 http://localhost:8000/docs
문서로 이동하여 URL을 앱의 올바른 URL로 바꾸세요.
이 프로젝트에 대한 기여를 환영합니다. 기여에 관심이 있다면 기여 가이드를 참조하세요.