Skip to content

Commit

Permalink
Merge pull request #32 from ZeusWPI/web_interface
Browse files Browse the repository at this point in the history
Web interface
  • Loading branch information
tyboro2002 authored Dec 26, 2024
2 parents a0806fc + 923ce29 commit 79a314f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
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

0 comments on commit 79a314f

Please sign in to comment.