Skip to content
Merged
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions api/auth/user_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import base64
import logging
from math import log
import os
import secrets
from functools import wraps
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions api/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
)
Expand Down
4 changes: 2 additions & 2 deletions api/routes/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
26 changes: 12 additions & 14 deletions app/templates/landing.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- Top header with logo -->
<header class="site-header" role="banner">
<div class="site-header-inner">
<img src="{{ url_for('static', path='icons/queryweaver.webp') }}" alt="QueryWeaver" />
<img src="{{ url_for('static', path='icons/queryweaver.webp') }}" alt="QueryWeaver" />
</div>
</header>

Expand Down Expand Up @@ -78,36 +78,36 @@
let typingTimer = null;
const typingSpeed = 15; // ms per character

function escapeHtml(s){
return s.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
function escapeHtml(s) {
return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}

// 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, '<span class="sql-string">$1</span>');
// 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 '<span class="sql-keyword">'+m+'</span>'; });
function (m) { return '<span class="sql-keyword">' + m + '</span>'; });
// aggregate/functions
out = out.replace(/\b(COUNT|SUM|AVG|MIN|MAX)\b/gi, function(m){ return '<span class="sql-func">'+m+'</span>'; });
out = out.replace(/\b(COUNT|SUM|AVG|MIN|MAX)\b/gi, function (m) { return '<span class="sql-func">' + m + '</span>'; });
// numbers
out = out.replace(/\b(\d+\.?\d*)\b/g, '<span class="sql-number">$1</span>');
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) {
Expand All @@ -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;
Expand Down Expand Up @@ -154,7 +154,6 @@
})();
</script>
</div>
</aside>

<!-- Feature boxes -->
<section class="features-row" aria-label="Key features">
Expand Down Expand Up @@ -207,5 +206,4 @@
</div>
</section>

</div>
{% endblock %}
Loading