8d382e723f
- Added Walmart scraper to scrape product data from Walmart.com, including category pages and product details. - Introduced a stealth browser module to handle bot protection and improve scraping reliability. - Created a SQLite database for tracking product history, price changes, stock events, and user favorites. - Developed a Discord bot for user interaction, allowing location setting and stock checking at local stores. - Implemented a favorites system to manage priority products and categories with custom notification settings. - Added news aggregation module to fetch and analyze Pokemon TCG news from various sources. - Created tools for API discovery and monitoring, including a backend monitor for detecting new products. - Added unit tests for database operations, product filtering, and API endpoints to ensure functionality. - Enhanced existing modules with improved error handling and logging for better maintainability.
78 lines
1.8 KiB
Python
78 lines
1.8 KiB
Python
"""
|
|
Flask dashboard for Pokemon Stock Monitor.
|
|
Provides web UI for stats visualization and favorites management.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add parent directory to path for imports
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
from flask import Flask, render_template, jsonify, request
|
|
from flask_cors import CORS
|
|
|
|
from src.database import get_database
|
|
from src.favorites import get_favorites_manager
|
|
from .api import api_bp
|
|
|
|
# Create Flask app
|
|
app = Flask(__name__)
|
|
CORS(app)
|
|
|
|
# Register API blueprint
|
|
app.register_blueprint(api_bp, url_prefix='/api')
|
|
|
|
|
|
@app.route('/')
|
|
def dashboard():
|
|
"""Main dashboard page"""
|
|
return render_template('index.html')
|
|
|
|
|
|
@app.route('/products')
|
|
def products_page():
|
|
"""Products listing page"""
|
|
return render_template('index.html', page='products')
|
|
|
|
|
|
@app.route('/news')
|
|
def news_page():
|
|
"""News aggregation page"""
|
|
return render_template('index.html', page='news')
|
|
|
|
|
|
@app.route('/analytics')
|
|
def analytics_page():
|
|
"""Analytics page"""
|
|
return render_template('index.html', page='analytics')
|
|
|
|
|
|
@app.route('/favorites')
|
|
def favorites_page():
|
|
"""Favorites management page"""
|
|
return render_template('index.html', page='favorites')
|
|
|
|
|
|
@app.route('/settings')
|
|
def settings_page():
|
|
"""Settings page"""
|
|
return render_template('index.html', page='settings')
|
|
|
|
|
|
@app.route('/users')
|
|
def users_page():
|
|
"""Users management page"""
|
|
return render_template('index.html', page='users')
|
|
|
|
|
|
def run_dashboard(host: str = '0.0.0.0', port: int = 5000, debug: bool = False):
|
|
"""Run the dashboard server"""
|
|
print(f"Starting Pokemon Stock Monitor Dashboard on http://{host}:{port}")
|
|
app.run(host=host, port=port, debug=debug, threaded=True)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
run_dashboard(debug=True)
|