Fix route config

Fix fts search
Log exceptions
master
Abdussamet Kocak 6 years ago
parent b38324770b
commit 3972c6e915

@ -42,7 +42,7 @@ async def list_locations(
return items
@api.get('/diyanet/search', response_model=List[PrayerTimes])
@api.get('/diyanet/search', response_model=List[Location])
async def search_location(
q: str,
conn: sqlite3.Connection = Depends(get_connection)):

@ -1,6 +1,16 @@
from fastapi import FastAPI
from loguru import logger
from starlette.requests import Request
from app.api import api as api_router
app = FastAPI()
app.include_router(api_router, prefix='/api')
@app.exception_handler(Exception)
async def log_exceptions(req: Request, err: Exception):
try:
raise err
except:
logger.exception(err)

@ -99,7 +99,7 @@ def find_location_by_name(conn: sqlite3.Connection, q: str) -> List[Location]:
WHERE locations_search match :q
ORDER BY country, city, region
'''
stmt = conn.execute(sql, {'q': f'%{q}%'})
stmt = conn.execute(sql, {'q': f'{q}'})
rows = stmt.fetchall()
if not rows:
return []

Loading…
Cancel
Save