Skip to content

Commit

Permalink
issue #18: default azure settings
Browse files Browse the repository at this point in the history
  • Loading branch information
k-allagbe committed Dec 19, 2023
1 parent 2251aa0 commit c7745c1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 1 addition & 3 deletions app/app_creator.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from flask import Flask
from flask_cors import CORS

from .config import Config


def create_app(config: Config):
def create_app(config):
app = Flask(__name__)
CORS(app)
app.config.from_object(config)
Expand Down
18 changes: 14 additions & 4 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

load_dotenv()

AZURE_SEARCH_ENDPOINT = ""
AZURE_SEARCH_INDEX_NAME = ""
AZURE_SEARCH_API_KEY = ""
DEFAULT_DEBUG_MODE = "False"
DEFAULT_ERROR_EMPTY_QUERY = "Search query cannot be empty"
DEFAULT_ERROR_AZURE_FAILED = "Azure index search failed."
Expand All @@ -21,15 +24,22 @@
DEFAULT_HIGHLIGHT_FIELDS = "content"
DEFAULT_HIGHLIGHT_TAG = "strong"


@dataclass
class Config:
AZURE_CONFIG = AzureIndexSearchConfig(
client=SearchClient(
os.getenv("FINESSE_BACKEND_AZURE_SEARCH_ENDPOINT"),
os.getenv("FINESSE_BACKEND_AZURE_SEARCH_INDEX_NAME"),
AzureKeyCredential(os.getenv("FINESSE_BACKEND_AZURE_SEARCH_API_KEY")),
os.getenv("FINESSE_BACKEND_AZURE_SEARCH_ENDPOINT", AZURE_SEARCH_ENDPOINT),
os.getenv(
"FINESSE_BACKEND_AZURE_SEARCH_INDEX_NAME", AZURE_SEARCH_INDEX_NAME
),
AzureKeyCredential(
os.getenv("FINESSE_BACKEND_AZURE_SEARCH_API_KEY", AZURE_SEARCH_API_KEY)
),
),
highlight_fields=os.getenv(
"FINESSE_BACKEND_HIGHLIGHT_FIELDS", DEFAULT_HIGHLIGHT_FIELDS
),
highlight_fields=os.getenv("FINESSE_BACKEND_HIGHLIGHT_FIELDS", DEFAULT_HIGHLIGHT_FIELDS),
highlight_tag=os.getenv("FINESSE_BACKEND_HIGHLIGHT_TAG", DEFAULT_HIGHLIGHT_TAG),
)
FINESSE_DATA_URL = os.getenv("FINESSE_BACKEND_STATIC_FILE_URL")
Expand Down

0 comments on commit c7745c1

Please sign in to comment.