diff --git a/Makefile b/Makefile
index 92a8ec80..64bf40d4 100644
--- a/Makefile
+++ b/Makefile
@@ -63,10 +63,10 @@ clean: ## Clean up test artifacts
find . -name "*.pyo" -delete
run-dev: build-dev ## Run development server
- pipenv run uvicorn api.index:app --host 127.0.0.1 --port 5000 --reload
+ pipenv run uvicorn api.index:app --host 127.0.0.1 --port $${PORT:-5000} --reload
run-prod: build-prod ## Run production server
- pipenv run uvicorn api.index:app --host 127.0.0.1 --port 5000
+ pipenv run uvicorn api.index:app --host 0.0.0.0 --port $${PORT:-5000}
docker-falkordb: ## Start FalkorDB in Docker for testing
docker run -d --name falkordb-test -p 6379:6379 falkordb/falkordb:latest
diff --git a/api/auth/user_management.py b/api/auth/user_management.py
index a33d9fdb..b49106da 100644
--- a/api/auth/user_management.py
+++ b/api/auth/user_management.py
@@ -2,6 +2,7 @@
import base64
import logging
+from math import log
import os
import secrets
from functools import wraps
@@ -35,14 +36,15 @@ async def _get_user_info(api_token: str) -> Optional[Dict[str, Any]]:
})
if result.result_set:
- token_valid = result.result_set[0][3]
+ single_result = result.result_set[0]
+ token_valid = single_result[3]
# TODO delete invalid token from DB
if token_valid:
return {
- "email": result.result_set[0][0],
- "name": result.result_set[0][1],
- "picture": result.result_set[0][2]
+ "email": single_result[0],
+ "name": single_result[1],
+ "picture": single_result[2]
}
return None
diff --git a/api/extensions.py b/api/extensions.py
index 1b6515f8..595056b2 100644
--- a/api/extensions.py
+++ b/api/extensions.py
@@ -3,7 +3,7 @@
import os
from falkordb.asyncio import FalkorDB
-from redis.asyncio import ConnectionPool
+from redis.asyncio import BlockingConnectionPool
# Connect to FalkorDB
url = os.getenv("FALKORDB_URL", None)
@@ -16,7 +16,7 @@
# Ensure the URL is properly encoded as string and handle potential encoding issues
try:
# Create connection pool with explicit encoding settings
- pool = ConnectionPool.from_url(
+ pool = BlockingConnectionPool.from_url(
url,
decode_responses=True
)
diff --git a/api/routes/auth.py b/api/routes/auth.py
index 1843b750..0fc6d8cf 100644
--- a/api/routes/auth.py
+++ b/api/routes/auth.py
@@ -166,7 +166,7 @@ async def google_authorized(request: Request) -> RedirectResponse:
# call the registered handler (await if async)
await handler('google', user_data, api_token)
- redirect = RedirectResponse(url="/", status_code=302)
+ redirect = RedirectResponse(url="/chat", status_code=302)
redirect.set_cookie(
key="api_token",
value=api_token,
@@ -249,7 +249,7 @@ async def github_authorized(request: Request) -> RedirectResponse:
# call the registered handler (await if async)
await handler('github', user_data, api_token)
- redirect = RedirectResponse(url="/", status_code=302)
+ redirect = RedirectResponse(url="/chat", status_code=302)
redirect.set_cookie(
key="api_token",
value=api_token,
diff --git a/app/templates/landing.j2 b/app/templates/landing.j2
index 38e9479a..b86478b7 100644
--- a/app/templates/landing.j2
+++ b/app/templates/landing.j2
@@ -10,7 +10,7 @@
@@ -78,36 +78,36 @@
let typingTimer = null;
const typingSpeed = 15; // ms per character
- function escapeHtml(s){
- return s.replace(/&/g,'&').replace(//g,'>');
+ function escapeHtml(s) {
+ return s.replace(/&/g, '&').replace(//g, '>');
}
// very small client-side SQL highlighter (runs after typing completes)
- function highlightSQL(sql){
- if(!sql) return '';
+ function highlightSQL(sql) {
+ if (!sql) return '';
// escape first
let out = escapeHtml(sql);
// strings (single quotes)
out = out.replace(/('[^']*')/g, '$1');
// keywords
out = out.replace(/\b(SELECT|FROM|JOIN|ON|WHERE|AND|OR|GROUP|BY|ORDER|LIMIT|AS|IN|IS|NULL|INNER|LEFT|RIGHT|OUTER)\b/gi,
- function(m){ return ''+m+''; });
+ function (m) { return '' + m + ''; });
// aggregate/functions
- out = out.replace(/\b(COUNT|SUM|AVG|MIN|MAX)\b/gi, function(m){ return ''+m+''; });
+ out = out.replace(/\b(COUNT|SUM|AVG|MIN|MAX)\b/gi, function (m) { return '' + m + ''; });
// numbers
out = out.replace(/\b(\d+\.?\d*)\b/g, '$1');
return out;
}
- function renderFull(i){
+ function renderFull(i) {
const ex = examples[i % examples.length];
- if(qEl) qEl.textContent = ex.q;
- if(sEl) {
+ if (qEl) qEl.textContent = ex.q;
+ if (sEl) {
sEl.classList.remove('typing');
// show highlighted SQL after typing completes
sEl.innerHTML = highlightSQL(ex.sql);
}
- if(successEl) successEl.style.display = 'flex';
+ if (successEl) successEl.style.display = 'flex';
}
function typeSql(text) {
@@ -125,7 +125,7 @@
typingTimer = setInterval(() => {
pos += 1;
// progressively render highlighted HTML for the substring so colors appear while typing
- if(sEl) sEl.innerHTML = highlightSQL(text.slice(0, pos));
+ if (sEl) sEl.innerHTML = highlightSQL(text.slice(0, pos));
if (pos >= text.length) {
clearInterval(typingTimer);
typingTimer = null;
@@ -154,7 +154,6 @@
})();
-
-
{% endblock %}
\ No newline at end of file