Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web interface #32

Merged
merged 3 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,6 @@ cython_debug/
.idea/

config.toml
bocca_takeaway.pdf
bocca_takeaway.pdf
hlds_files
db.json
8 changes: 7 additions & 1 deletion website/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from datetime import datetime

from flask import Flask, render_template, jsonify
import subprocess
from apscheduler.schedulers.background import BackgroundScheduler

# Add the parent directory to the system path to allow imports from the higher-level directory
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
Expand Down Expand Up @@ -160,6 +160,7 @@ def init_db():
""", restaurants)
conn.commit()


@app.route("/")
def home():
scraper_info = get_scraper_info()
Expand All @@ -181,6 +182,11 @@ def sync_all_files():
return jsonify({"error": str(e)}), 500


scheduler = BackgroundScheduler()
scheduler.add_job(scrape_all, 'interval', minutes=30) # Scrape every 30 minutes
scheduler.add_job(sync_all_files, 'interval', minutes=30) # Sync every 30 minutes
scheduler.start()

if __name__ == "__main__":
# Initialize the database when the app starts
init_db()
Expand Down
4 changes: 2 additions & 2 deletions website/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@

// Set interval to update scraper table every 5 seconds
setInterval(updateScraperTable, 5000);
setInterval(scrapeAllRestaurants, 30 * 60 * 1000); // 30 minutes in milliseconds
setInterval(syncAll, 30 * 60 * 1000); // 30 minutes in milliseconds
{#setInterval(scrapeAllRestaurants, 30 * 60 * 1000); // 30 minutes in milliseconds#}
{#setInterval(syncAll, 30 * 60 * 1000); // 30 minutes in milliseconds#}
</script>
</head>
<body>
Expand Down
Loading