Skip to content

Commit 9e69590

Browse files
committed
Add Sustainable Travel Planner project (Issue #91)
1 parent 1f01422 commit 9e69590

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Sustainable Travel Planner
2+
3+
A simple sustainable travel planning application to promote eco-friendly travel, reduce carbon footprint, and support local communities.
4+
5+
## Features
6+
- Suggests eco-friendly destinations and activities
7+
- Displays eco score for each suggestion
8+
9+
## Usage
10+
1. Install dependencies:
11+
```bash
12+
pip install flask
13+
```
14+
2. Run the Flask app:
15+
```bash
16+
python app.py
17+
```
18+
3. Open your browser at `http://localhost:5000`.
19+
20+
## Requirements
21+
- Python 3.x
22+
- Flask
23+
24+
## License
25+
MIT

Sustainable_Travel_Planner/app.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Sustainable Travel Planner (Issue #91)
3+
Minimal Flask backend + HTML/JS frontend
4+
"""
5+
from flask import Flask, request, jsonify, send_from_directory
6+
import os
7+
8+
app = Flask(__name__)
9+
10+
SUGGESTIONS = [
11+
{"destination": "Amsterdam", "activity": "Bike tours, local markets", "eco_score": 9},
12+
{"destination": "Costa Rica", "activity": "Rainforest hikes, eco-lodges", "eco_score": 10},
13+
{"destination": "Kyoto", "activity": "Temple visits, public transport", "eco_score": 8},
14+
{"destination": "Vancouver", "activity": "Urban parks, cycling", "eco_score": 8},
15+
{"destination": "New Zealand", "activity": "Nature reserves, local farms", "eco_score": 9}
16+
]
17+
18+
@app.route("/api/suggestions", methods=["GET"])
19+
def suggestions():
20+
return jsonify(SUGGESTIONS)
21+
22+
@app.route("/")
23+
def index():
24+
return send_from_directory(".", "sustainable.html")
25+
26+
if __name__ == "__main__":
27+
app.run(debug=True)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flask
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Sustainable Travel Planner</title>
6+
<style>
7+
body { font-family: Arial, sans-serif; margin: 40px; }
8+
.container { max-width: 600px; margin: auto; }
9+
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
10+
th, td { border: 1px solid #ccc; padding: 8px; text-align: left; }
11+
th { background: #e0f7fa; }
12+
</style>
13+
</head>
14+
<body>
15+
<div class="container">
16+
<h2>Sustainable Travel Planner</h2>
17+
<p>Discover eco-friendly destinations and activities to reduce your carbon footprint and support local communities.</p>
18+
<table>
19+
<thead>
20+
<tr>
21+
<th>Destination</th>
22+
<th>Activity</th>
23+
<th>Eco Score</th>
24+
</tr>
25+
</thead>
26+
<tbody id="suggestionTable"></tbody>
27+
</table>
28+
</div>
29+
<script>
30+
function fetchSuggestions() {
31+
fetch('/api/suggestions').then(r => r.json()).then(data => {
32+
const table = document.getElementById('suggestionTable');
33+
table.innerHTML = '';
34+
data.forEach(s => {
35+
const row = `<tr><td>${s.destination}</td><td>${s.activity}</td><td>${s.eco_score}/10</td></tr>`;
36+
table.innerHTML += row;
37+
});
38+
});
39+
}
40+
fetchSuggestions();
41+
</script>
42+
</body>
43+
</html>

0 commit comments

Comments
 (0)