Skip to content

Commit 1f01422

Browse files
committed
Add Travel Itinerary Planner project (Issue #92)
1 parent cb4eec0 commit 1f01422

File tree

4 files changed

+125
-0
lines changed

4 files changed

+125
-0
lines changed

Travel_Itinerary_Planner/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Travel Itinerary Planner
2+
3+
A simple travel itinerary planner to create, save, and share travel plans including places to visit, accommodations, and activities.
4+
5+
## Features
6+
- Add and view itineraries
7+
- Map preview for places to visit (Google Maps embed)
8+
- Save trip details
9+
10+
## Usage
11+
1. Install dependencies:
12+
```bash
13+
pip install flask
14+
```
15+
2. Run the Flask app:
16+
```bash
17+
python app.py
18+
```
19+
3. Open your browser at `http://localhost:5000`.
20+
4. For map preview, replace `YOUR_API_KEY` in `planner.html` with your Google Maps Embed API key.
21+
22+
## Requirements
23+
- Python 3.x
24+
- Flask
25+
- Google Maps Embed API key (for map preview)
26+
27+
## License
28+
MIT

Travel_Itinerary_Planner/app.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
Travel Itinerary Planner (Issue #92)
3+
Minimal Flask backend + HTML/JS frontend with Google Maps embed
4+
"""
5+
from flask import Flask, request, jsonify, send_from_directory
6+
import os
7+
8+
app = Flask(__name__)
9+
10+
ITINERARIES = []
11+
12+
@app.route("/api/itineraries", methods=["GET", "POST"])
13+
def itineraries():
14+
if request.method == "POST":
15+
itinerary = request.json
16+
ITINERARIES.append(itinerary)
17+
return jsonify({"status": "added"}), 201
18+
return jsonify(ITINERARIES)
19+
20+
@app.route("/")
21+
def index():
22+
return send_from_directory(".", "planner.html")
23+
24+
if __name__ == "__main__":
25+
app.run(debug=True)
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Travel Itinerary Planner</title>
6+
<style>
7+
body { font-family: Arial, sans-serif; margin: 40px; }
8+
.container { max-width: 700px; margin: auto; }
9+
input, button, textarea { margin: 5px; }
10+
textarea { width: 100%; height: 60px; }
11+
</style>
12+
</head>
13+
<body>
14+
<div class="container">
15+
<h2>Travel Itinerary Planner</h2>
16+
<div>
17+
<label>Trip Name: </label>
18+
<input type="text" id="tripName" />
19+
</div>
20+
<div>
21+
<label>Places to Visit (comma separated): </label>
22+
<input type="text" id="places" />
23+
</div>
24+
<div>
25+
<label>Accommodations: </label>
26+
<input type="text" id="accommodations" />
27+
</div>
28+
<div>
29+
<label>Activities: </label>
30+
<textarea id="activities"></textarea>
31+
</div>
32+
<button onclick="addItinerary()">Save Itinerary</button>
33+
<h3>Saved Itineraries</h3>
34+
<ul id="itineraryList"></ul>
35+
<h3>Map Preview</h3>
36+
<iframe id="mapFrame" width="600" height="400" style="border:0" allowfullscreen loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
37+
</div>
38+
<script>
39+
function addItinerary() {
40+
const trip = {
41+
name: document.getElementById('tripName').value,
42+
places: document.getElementById('places').value.split(','),
43+
accommodations: document.getElementById('accommodations').value,
44+
activities: document.getElementById('activities').value
45+
};
46+
fetch('/api/itineraries', {
47+
method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(trip)
48+
}).then(fetchItineraries);
49+
}
50+
function fetchItineraries() {
51+
fetch('/api/itineraries').then(r => r.json()).then(data => {
52+
const list = document.getElementById('itineraryList');
53+
list.innerHTML = '';
54+
data.forEach((it, idx) => {
55+
const li = document.createElement('li');
56+
li.innerHTML = `<b>${it.name}</b>: Places - ${it.places.join(', ')}, Accommodations - ${it.accommodations}, Activities - ${it.activities} <button onclick='showMap(${idx})'>Show Map</button>`;
57+
list.appendChild(li);
58+
});
59+
});
60+
}
61+
function showMap(idx) {
62+
fetch('/api/itineraries').then(r => r.json()).then(data => {
63+
const places = data[idx].places.map(p => encodeURIComponent(p.trim())).join('%2C');
64+
const url = `https://www.google.com/maps/embed/v1/search?key=YOUR_API_KEY&q=${places}`;
65+
document.getElementById('mapFrame').src = url;
66+
});
67+
}
68+
fetchItineraries();
69+
</script>
70+
</body>
71+
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flask

0 commit comments

Comments
 (0)