Include interfaces in pip package. Fix paths to web interface in app

This commit is contained in:
Debanjum Singh Solanky 2022-08-03 00:02:39 +03:00
parent 765e10bc2c
commit b9e6273644
2 changed files with 7 additions and 4 deletions

View file

@ -7,7 +7,7 @@ this_directory = Path(__file__).parent
setup(
name='khoj-assistant',
version='0.1',
version='0.1.3',
description="A natural language search engine for your personal notes, transactions and images",
long_description=(this_directory / "Readme.md").read_text(encoding="utf-8"),
long_description_content_type="text/markdown",
@ -40,6 +40,7 @@ setup(
"aiofiles == 0.8.0",
"dateparser == 1.1.1",
],
include_package_data=True,
entry_points={"console_scripts": ["khoj = src.main:run"]},
classifiers=[
"Development Status :: 4 - Beta",

View file

@ -2,6 +2,7 @@
import sys, json, yaml, os
import time
from typing import Optional
from pathlib import Path
# External Packages
import uvicorn
@ -31,14 +32,15 @@ processor_config = ProcessorConfigModel()
config_file = ""
verbose = 0
app = FastAPI()
web_directory = f'src/interface/web/'
this_directory = Path(__file__).parent
web_directory = this_directory / 'interface/web/'
app.mount("/static", StaticFiles(directory=web_directory), name="static")
templates = Jinja2Templates(directory=web_directory)
@app.get("/", response_class=FileResponse)
def index():
return FileResponse(web_directory + "index.html")
return FileResponse(web_directory / "index.html")
@app.get('/config', response_class=HTMLResponse)
def ui(request: Request):
@ -116,7 +118,7 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None, r: Opti
# query images
query_start = time.time()
hits = image_search.query(user_query, results_count, model.image_search)
output_directory = f'{os.getcwd()}/{web_directory}/images'
output_directory = web_directory / 'images'
query_end = time.time()
# collate and return results