This project is a web application that allows users to fetch sunrise and sunset timings for a selected or current location. Users can interact with a map to update their location, view the solar data for today and tomorrow, and explore details like dawn, dusk, and golden hours. The app uses a Flask backend as a proxy server to handle API requests while overcoming CORS issues.
- Interactive map for selecting locations.
- Fetch sunrise and sunset data for any location.
- View timezone and detailed solar information for today and tomorrow.
- Use your current location with the "Use Current Location" button.
- Change background dynamically based on the selected location's time and season.
- HTML, CSS, JavaScript
- Leaflet.js for interactive maps
- Python with Flask
- Flask-CORS for handling CORS issues
Ensure Python (3.x) is installed, then run:
pip install flask flask-cors requestsThe server acts as a proxy for external APIs to handle CORS issues. To start the server:
python server.pyBy default, the server will run on http://localhost:5000.
Navigate to the project directory and open the index.html file in your browser.
- Select a Location: Choose from predefined options in the dropdown.
- Map Interaction: Click or drag the marker on the map to select a custom location.
- Use Current Location: Click the "Use Current Location" button to get data for your current coordinates.
When running a Flask backend, browsers enforce CORS rules, which prevent the frontend from accessing APIs directly due to security restrictions. By using a Flask backend:
- We overcome these restrictions using a proxy server.
- The
Flask-CORSlibrary ensures the backend adds necessary headers (Access-Control-Allow-Origin) to allow secure communication between the frontend and backend.
- Interactive Map: Drag or click on the map to update the location and fetch solar data.
- Predefined Locations: Select from the dropdown for quick access to common locations.
- Background Updates: Background images change dynamically based on the time and season of the selected location.
-
Flask Server Not Running:
- Ensure Python is installed.
- Verify all dependencies are installed using
pip list.
-
CORS Errors:
- Ensure
Flask-CORSis installed and enabled inserver.py.
- Ensure
-
API Key Errors:
- Replace placeholder API keys in
server.pywith valid keys from the respective APIs.
- Replace placeholder API keys in
sunrise-dashboard/
│
├── assets/
│ └── images/ # Background images for seasons and times of the day
├── scripts/
│ ├── main.js # Core functionality for frontend interactions
│ ├── dataDisplay.js # Handles displaying solar data
├── styles.css # Styling for the application
├── index.html # Main HTML file
└── server.py # Flask backend proxy server




