Latest stable branch includes sermon analysis endpoint, but not required for new installations

This commit is contained in:
2024-11-12 17:25:56 -08:00
parent 0ab32bf4e2
commit 87f0dc54c5
16 changed files with 376 additions and 70 deletions
+2 -1
View File
@@ -1,2 +1,3 @@
KJV_SERMON_DB="/home/tyler/kjv-api/sermon-analyzer/data/sermons.db" KJV_SERMON_DB="./data/sermons.db"
# this does not do anything unless sermon_analyzer.py is running in tcp socket mode as a separate process
KJV_SECRET_API_KEY="testing" KJV_SECRET_API_KEY="testing"
+2
View File
@@ -0,0 +1,2 @@
logs/*.log
*__pycache__*
+4
View File
@@ -744,6 +744,10 @@ def make_view(response_list=[]):
response = jsonify(response_list) response = jsonify(response_list)
@app.get("/fe")
def frontend():
return send_file('kjv_fe.html')
@app.get("/search") # user-facing keyword search. To be moved to backend, possibly replaced with semantic search. @app.get("/search") # user-facing keyword search. To be moved to backend, possibly replaced with semantic search.
def search(): def search():
keywords = request.args.get("kw", None) keywords = request.args.get("kw", None)
+3
View File
@@ -0,0 +1,3 @@
https://www.sqlite.org/fts5.html
4.3.4. The Trigram Tokenizer
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
+67 -21
View File
@@ -3,23 +3,83 @@
<html> <html>
<head> <head>
<style> <style>
/* Dark Theme */
body {
background-color: #222;
color: #fff;
}
/* Style the header */
html { html {
font-family: sans-serif; font-family: sans-serif;
font-size: 14pt; font-size: 14.5pt;
width: 768px;
padding: 1px;
margin-top: 15px;
color: #fff; /* Text color */
}
a {
color: #007bff; /* Link color */
}
.header {
font-family: sans-serif;
padding: 10px 16px;
background: #333; /* Dark background */
color: #fff; /* Text color */
position: fixed;
top: 5px;
width: 768px; width: 768px;
} }
a {
color: #547720 input[type=text] {
width: 75%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
text-align: left;
font-size: 14.5pt;
background-color: #333; /* Dark background */
color: #fff; /* Text color */
border: 1px solid #555; /* Border color */
}
input[type=button], input[type=submit], input[type=reset] {
font-family: sans-serif;
background-color: #555; /* Dark button background */
border: none;
color: #fff; /* Button text color */
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
}
code {
background-color: #222;
color: #fff;
padding: 4px 8px;
border-radius: 4px;
font-family: monospace;
}
.definition {
padding: 8px;
font-family: sans-serif;
font-size: 14.5pt;
width: 768px;
padding: 1px;
color: #fff; /* Text color */
background-color: #222; /* Dark background */
} }
</style> </style>
</head> </head>
<h1>KJV API</h1> <h1>KJV API (Legacy edition)</h1>
<p>KJV accessible via web calls</p>
<h2>Quick Search</h2>
<form action="/find"> <form action="/find">
<label for='kw'>Query</label><br> <label for='kw'>Keyword Search</label><br>
<input type="text" name="kw"><br><br> <input type="text" name="kw"><br><br>
<input type="hidden" name="view" value="rich""> <input type="hidden" name="view" value="rich"">
<input type="submit"> <input type="submit">
@@ -76,9 +136,6 @@ num=
- Used only with /seq - Used only with /seq
- You can get the "next # verses" in your sequence - You can get the "next # verses" in your sequence
FEATURES FEATURES
======== ========
- King James Only. (No heretical commentaries or false Bibles) - King James Only. (No heretical commentaries or false Bibles)
@@ -101,17 +158,6 @@ EXAMPLES
api.tld/random api.tld/random
api.tld/votd?view=rich api.tld/votd?view=rich
api.tld/show?kw=john3:16,1john5:7&view=plain api.tld/show?kw=john3:16,1john5:7&view=plain
api.tld/search?kw=faith
api.tld/search?kw=nimrod&view=rich
api.tld/define?kw=faith&view=rich
api.tld/define?kw=faith&view=rich
api.tld/seq?getuid=true&start=2peter2:1
api.tld/seq?uid=075a8496-9af7-4f44-84ec-ba3e7fa6de29&view=rich
INTEGRATION
===========
If you want to put the verse of the day into your website, you can use the following example php:
echo curl_exec(curl_init('https://api.1611.social/votd?view=plain'));
BUGS BUGS
==== ====
+2 -2
View File
@@ -2,9 +2,9 @@
# run from current directory only # run from current directory only
FILE=app.py FILE=app.py
if test -f "$FILE"; then if test -f "$FILE"; then
uwsgi_python3 --http-socket 0.0.0.0:1612 --wsgi-file app.py --callable app --pyargv "-vvv" --stats 0.0.0.0:9192 uwsgi_python310 --http-socket 0.0.0.0:1612 --wsgi-file app.py --callable app --pyargv "-vvv" --stats 0.0.0.0:9192
else else
cd /opt/kjv-api cd /opt/kjv-api
echo "WARNING: RUNNING FROM /opt/kjv-api" echo "WARNING: RUNNING FROM /opt/kjv-api"
uwsgi_python3 --http-socket 0.0.0.0:1612 --wsgi-file /opt/kjv-api/app.py --callable app --pyargv "-vvv" uwsgi_python310 --http-socket 0.0.0.0:1612 --wsgi-file /opt/kjv-api/app.py --callable app --pyargv "-vvv"
fi fi
+1 -1
View File
@@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
cd /opt/kjv-api cd /opt/kjv-api
uwsgi_python3 --http-socket :1611 --wsgi-file /opt/kjv-api/app.py --callable app --stats 127.0.0.1:9191 uwsgi_python312 --http-socket :1611 --wsgi-file /opt/kjv-api/app.py --callable app --stats 127.0.0.1:9191
+115
View File
@@ -0,0 +1,115 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search</title>
<style>
#search-box {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
width: 100%;
margin-bottom: 10px;
}
#results {
list-style: none;
padding: 0;
}
#results li {
margin-bottom: 10px;
border-bottom: 1px solid #eee;
padding: 5px;
}
</style>
</head>
<body>
<h1>Bible Semantic Search</h1>
<p>This is NOT a keyword search. This means searching single words will not have the results you expect. For that, use the normal keyword search at <a href='/'>api.1611.social</a></p>
<p>Use a sentence like "The Lord will kill his enemies without mercy" - you are supposed to search an idea, not individual words.</p>
<h3>Recent searches:</h3>
<ul id="last-searched"></ul>
<input type="text" id="search-box" placeholder="The lord god is a man of war, just in all his dealings">
<button id="search-button">Search</button>
<ul id="results"></ul>
<script>
const searchButton = document.getElementById('search-button');
const searchBox = document.getElementById('search-box');
const resultsList = document.getElementById('results');
const lastSearched = document.getElementById('last-searched');
window.addEventListener('DOMContentLoaded', async () => {
const lastSearchedURL = `https://api.1611.social/natural`;
const data = {
token: 'testing',
query: '__last_searched__'
};
const response = await fetch(lastSearchedURL, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
if (response.ok) {
const results = await response.json();
lastSearched.innerHTML = ''; // Clear previous results
results.forEach(result => {
const listItem = document.createElement('li');
listItem.innerHTML = `
${result.query}<br>
`;
lastSearched.appendChild(listItem);
});
} else {
console.error('Error fetching data:', response.statusText);
}
});
searchButton.addEventListener('click', async () => {
const query = searchBox.value;
if (query.length >= 100){
alert("Query too long");
return;}
const url = `https://api.1611.social/natural`; // Replace with your actual URL
const data = {
token: 'testing',
query: query
};
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
if (response.ok) {
const results = await response.json();
resultsList.innerHTML = ''; // Clear previous results
results.forEach(result => {
const listItem = document.createElement('li');
const uriRef = encodeURIComponent(result.ref);
listItem.innerHTML = `
<strong>Verse ID:</strong> ${result.verse_id}<br>
<strong>Text:</strong> ${result.text}<br>
<strong>Ref:</strong> <a href=/find?kw=${uriRef}>${result.ref}</a><br>
<strong>Score:</strong> ${result.score}
`;
resultsList.appendChild(listItem);
});
} else {
console.error('Error fetching data:', response.statusText);
alert('An error occurred while searching. Please try again later.');
}
});
</script>
</body>
</html>
View File
+25 -10
View File
@@ -1,27 +1,38 @@
<style> <style>
/* Style the header */ /* Dark Theme */
body {
background-color: #222;
color: #fff;
}
/* Style the header */
.responses { .responses {
font-family: sans-serif; font-family: sans-serif;
font-size: 14.5pt; font-size: 14.5pt;
width: 768px; width: 768px;
padding: 1px; padding: 1px;
margin-top: 100px; margin-top: 100px;
color: #fff; /* Text color */
width: auto;
max-width: 100%; /* Ensure it doesn't exceed the container width */
white-space: pre-wrap; /* Allow word wrapping */
} }
a { a {
color: #547720 color: #007bff; /* Link color */
} }
.header { .header {
font-family: sans-serif; font-family: sans-serif;
padding: 10px 16px; padding: 10px 16px;
background: #dbd5d5; background: #333; /* Dark background */
color: #1a1919; color: #fff; /* Text color */
position: fixed; position: fixed;
top: 5px; top: 5px;
width: 768px; width: 98vw;
max-width: 100%; /* Ensure it doesn't exceed the container width */
min-height: 50px;
} }
input[type=text] { input[type=text] {
@@ -31,25 +42,29 @@
box-sizing: border-box; box-sizing: border-box;
text-align: left; text-align: left;
font-size: 14.5pt; font-size: 14.5pt;
background-color: #333; /* Dark background */
color: #fff; /* Text color */
border: 1px solid #555; /* Border color */
} }
input[type=button], input[type=submit], input[type=reset] { input[type=button], input[type=submit], input[type=reset] {
font-family: sans-serif; font-family: sans-serif;
background-color: #afcdc2; background-color: #555; /* Dark button background */
border: none; border: none;
color: rgb(0, 0, 0); color: #fff; /* Button text color */
padding: 16px 32px; padding: 16px 32px;
text-decoration: none; text-decoration: none;
margin: 4px 2px; margin: 4px 2px;
cursor: pointer; cursor: pointer;
} }
/* Page content */
.definition { .definition {
padding: 8px; padding: 8px;
font-family: sans-serif; font-family: sans-serif;
font-size: 14.5pt; font-size: 14.5pt;
width: 768px; width: 768px;
padding: 1px; padding: 1px;
color: #fff; /* Text color */
background-color: #222; /* Dark background */
} }
</style> </style>
+65
View File
@@ -0,0 +1,65 @@
<style>
/* Dark Theme */
body {
background-color: #222;
color: #fff;
}
/* Style the header */
.responses {
font-family: sans-serif;
font-size: 14.5pt;
width: 768px;
padding: 1px;
margin-top: 100px;
color: #fff; /* Text color */
}
a {
color: #007bff; /* Link color */
}
.header {
font-family: sans-serif;
padding: 10px 16px;
background: #333; /* Dark background */
color: #fff; /* Text color */
position: fixed;
top: 5px;
width: 768px;
}
input[type=text] {
width: 75%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
text-align: left;
font-size: 14.5pt;
background-color: #333; /* Dark background */
color: #fff; /* Text color */
border: 1px solid #555; /* Border color */
}
input[type=button], input[type=submit], input[type=reset] {
font-family: sans-serif;
background-color: #555; /* Dark button background */
border: none;
color: #fff; /* Button text color */
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
}
.definition {
padding: 8px;
font-family: sans-serif;
font-size: 14.5pt;
width: 768px;
padding: 1px;
color: #fff; /* Text color */
background-color: #222; /* Dark background */
}
</style>
+55
View File
@@ -0,0 +1,55 @@
<style>
/* Style the header */
.responses{
font-family: sans-serif;
font-size: 14.5pt;
width: 768px;
padding: 1px;
margin-top: 100px;
}
a {
color: #547720
}
.header {
font-family: sans-serif;
padding: 10px 16px;
background: #dbd5d5;
color: #1a1919;
position: fixed;
top: 5px;
width: 768px;
}
input[type=text] {
width: 75%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
text-align: left;
font-size: 14.5pt;
}
input[type=button], input[type=submit], input[type=reset] {
font-family: sans-serif;
background-color: #afcdc2;
border: none;
color: rgb(0, 0, 0);
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
}
/* Page content */
.definition {
padding: 8px;
font-family: sans-serif;
font-size: 14.5pt;
width: 768px;
padding: 1px;
}
</style>