Create Basic Landing Page to Query Semantic Search and Render Results

- Allow viewing image results returned by Semantic Search.
  Until now there wasn't any interface within the app to view image
  search results. For text results, we at least had the emacs interface

- This should help with debugging issues with image search too
  For text the Swagger interface was good enough
This commit is contained in:
Debanjum Singh Solanky
2022-07-15 22:07:39 +04:00
parent 4e27ae0577
commit a6aef62a99
3 changed files with 89 additions and 3 deletions

View File

@@ -1,12 +1,12 @@
# Standard Packages
import sys, json, yaml
import sys, json, yaml, os
from typing import Optional
# External Packages
import uvicorn
import torch
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.responses import HTMLResponse, FileResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
@@ -27,10 +27,16 @@ processor_config = ProcessorConfigModel()
config_file = ""
verbose = 0
app = FastAPI()
web_directory = f'src/interface/web/'
app.mount("/static", StaticFiles(directory=web_directory), name="static")
app.mount("/views", StaticFiles(directory="views"), name="views")
templates = Jinja2Templates(directory="views/")
@app.get("/", response_class=FileResponse)
def index():
return FileResponse(web_directory + "index.html")
@app.get('/ui', response_class=HTMLResponse)
def ui(request: Request):
return templates.TemplateResponse("config.html", context={'request': request})