Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,13 +3,15 @@ from datetime import datetime, timedelta
|
|
| 3 |
import json
|
| 4 |
import os
|
| 5 |
import uuid
|
| 6 |
-
import
|
|
|
|
|
|
|
| 7 |
|
| 8 |
app = Flask(__name__)
|
| 9 |
app.secret_key = os.environ.get('SECRET_KEY', 'dev-secret-key')
|
| 10 |
app.config['SESSION_TYPE'] = 'filesystem'
|
| 11 |
|
| 12 |
-
# Sample data for Indian museums
|
| 13 |
MUSEUMS = {
|
| 14 |
"national_museum": {
|
| 15 |
"id": "national_museum",
|
|
@@ -22,7 +24,10 @@ MUSEUMS = {
|
|
| 22 |
"timings": "10:00 AM - 6:00 PM",
|
| 23 |
"closed_on": "Monday",
|
| 24 |
"best_for": ["History", "Archaeology", "Art"],
|
| 25 |
-
"rating": 4.5
|
|
|
|
|
|
|
|
|
|
| 26 |
},
|
| 27 |
"indian_museum": {
|
| 28 |
"id": "indian_museum",
|
|
@@ -35,7 +40,10 @@ MUSEUMS = {
|
|
| 35 |
"timings": "10:00 AM - 5:00 PM",
|
| 36 |
"closed_on": "Monday",
|
| 37 |
"best_for": ["Ancient History", "Natural History", "Art"],
|
| 38 |
-
"rating": 4.3
|
|
|
|
|
|
|
|
|
|
| 39 |
},
|
| 40 |
"chhatrapati_museum": {
|
| 41 |
"id": "chhatrapati_museum",
|
|
@@ -48,7 +56,10 @@ MUSEUMS = {
|
|
| 48 |
"timings": "10:15 AM - 6:00 PM",
|
| 49 |
"closed_on": "Monday",
|
| 50 |
"best_for": ["Architecture", "Sculptures", "Paintings"],
|
| 51 |
-
"rating": 4.7
|
|
|
|
|
|
|
|
|
|
| 52 |
},
|
| 53 |
"salar_jung": {
|
| 54 |
"id": "salar_jung",
|
|
@@ -61,7 +72,10 @@ MUSEUMS = {
|
|
| 61 |
"timings": "10:00 AM - 5:00 PM",
|
| 62 |
"closed_on": "Friday",
|
| 63 |
"best_for": ["Personal Collections", "Artifacts", "Manuscripts"],
|
| 64 |
-
"rating": 4.4
|
|
|
|
|
|
|
|
|
|
| 65 |
}
|
| 66 |
}
|
| 67 |
|
|
@@ -85,6 +99,7 @@ CHATBOT_RESPONSES = {
|
|
| 85 |
{"text": "๐ Language Support", "value": "languages"},
|
| 86 |
{"text": "๐ฐ Pricing Info", "value": "pricing"},
|
| 87 |
{"text": "โฐ Timings", "value": "timings"},
|
|
|
|
| 88 |
{"text": "โ General Help", "value": "help"}
|
| 89 |
]
|
| 90 |
},
|
|
@@ -135,34 +150,56 @@ CHATBOT_RESPONSES = {
|
|
| 135 |
{"text": "๐ Back to Main Menu", "value": "back"}
|
| 136 |
]
|
| 137 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
"help": {
|
| 139 |
-
"message": "I can help you with: ticket booking, museum information, pricing, timings, and language support. What would you like to know?",
|
| 140 |
"options": [
|
| 141 |
{"text": "๐ซ Book Tickets", "value": "book_tickets"},
|
| 142 |
{"text": "๐๏ธ Museum Info", "value": "best_museums"},
|
|
|
|
| 143 |
{"text": "๐ Back to Main Menu", "value": "back"}
|
| 144 |
]
|
| 145 |
}
|
| 146 |
}
|
| 147 |
|
| 148 |
-
# Store bookings
|
| 149 |
bookings = {}
|
| 150 |
-
payment_sessions = {}
|
| 151 |
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
@app.route('/')
|
| 160 |
def home():
|
| 161 |
-
return render_template('index.html'
|
| 162 |
|
| 163 |
@app.route('/museums')
|
| 164 |
def museums():
|
| 165 |
-
return render_template('museums.html', museums=MUSEUMS
|
| 166 |
|
| 167 |
@app.route('/museum/<museum_id>')
|
| 168 |
def museum_detail(museum_id):
|
|
@@ -170,99 +207,72 @@ def museum_detail(museum_id):
|
|
| 170 |
if not museum:
|
| 171 |
return redirect(url_for('museums'))
|
| 172 |
|
| 173 |
-
# Set current date for minimum date in form
|
| 174 |
current_date = datetime.now().strftime('%Y-%m-%d')
|
| 175 |
-
return render_template('booking.html', museum=museum, time_slots=TIME_SLOTS, now=current_date
|
| 176 |
|
| 177 |
-
@app.route('/api/
|
| 178 |
-
def
|
| 179 |
try:
|
| 180 |
data = request.get_json()
|
| 181 |
-
museum_id = data.get('museum_id')
|
| 182 |
-
visitors = int(data.get('visitors', 1))
|
| 183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
if museum_id not in MUSEUMS:
|
| 185 |
return jsonify({'success': False, 'error': 'Invalid museum'})
|
| 186 |
|
|
|
|
| 187 |
museum = MUSEUMS[museum_id]
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
-
|
| 191 |
-
order_id = f"order_{uuid.uuid4().hex[:16]}"
|
| 192 |
|
| 193 |
-
|
| 194 |
-
|
| 195 |
'museum_id': museum_id,
|
| 196 |
-
'
|
| 197 |
-
'
|
| 198 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
}
|
| 200 |
|
|
|
|
|
|
|
| 201 |
return jsonify({
|
| 202 |
'success': True,
|
| 203 |
-
'
|
| 204 |
-
'
|
| 205 |
-
'currency': RAZORPAY_CONFIG['currency'],
|
| 206 |
-
'key_id': RAZORPAY_CONFIG['key_id']
|
| 207 |
})
|
| 208 |
|
| 209 |
except Exception as e:
|
| 210 |
return jsonify({'success': False, 'error': str(e)})
|
| 211 |
|
| 212 |
-
@app.route('/api/verify-payment', methods=['POST'])
|
| 213 |
-
def verify_payment():
|
| 214 |
-
try:
|
| 215 |
-
data = request.get_json()
|
| 216 |
-
payment_id = data.get('razorpay_payment_id')
|
| 217 |
-
order_id = data.get('razorpay_order_id')
|
| 218 |
-
signature = data.get('razorpay_signature')
|
| 219 |
-
|
| 220 |
-
# In production, verify signature using Razorpay secret key
|
| 221 |
-
# For demo, we'll assume payment is successful
|
| 222 |
-
is_payment_valid = True # Simplified for demo
|
| 223 |
-
|
| 224 |
-
if is_payment_valid and order_id in payment_sessions:
|
| 225 |
-
order_data = payment_sessions[order_id]
|
| 226 |
-
|
| 227 |
-
# Generate booking ID
|
| 228 |
-
booking_id = str(uuid.uuid4())[:8].upper()
|
| 229 |
-
|
| 230 |
-
# Create booking record
|
| 231 |
-
booking = {
|
| 232 |
-
'booking_id': booking_id,
|
| 233 |
-
'museum_id': order_data['museum_id'],
|
| 234 |
-
'museum_name': MUSEUMS[order_data['museum_id']]['name'],
|
| 235 |
-
'visit_date': data.get('visit_date'),
|
| 236 |
-
'time_slot': data.get('time_slot'),
|
| 237 |
-
'visitors': order_data['visitors'],
|
| 238 |
-
'total_amount': order_data['amount'] / 100, # Convert back to rupees
|
| 239 |
-
'customer_name': data.get('name'),
|
| 240 |
-
'customer_email': data.get('email'),
|
| 241 |
-
'customer_phone': data.get('phone'),
|
| 242 |
-
'language': data.get('language', 'English'),
|
| 243 |
-
'payment_id': payment_id,
|
| 244 |
-
'order_id': order_id,
|
| 245 |
-
'booking_date': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
| 246 |
-
'status': 'confirmed'
|
| 247 |
-
}
|
| 248 |
-
|
| 249 |
-
# Store booking
|
| 250 |
-
bookings[booking_id] = booking
|
| 251 |
-
|
| 252 |
-
# Clean up payment session
|
| 253 |
-
del payment_sessions[order_id]
|
| 254 |
-
|
| 255 |
-
return jsonify({
|
| 256 |
-
'success': True,
|
| 257 |
-
'booking_id': booking_id,
|
| 258 |
-
'message': 'Payment verified successfully'
|
| 259 |
-
})
|
| 260 |
-
else:
|
| 261 |
-
return jsonify({'success': False, 'error': 'Payment verification failed'})
|
| 262 |
-
|
| 263 |
-
except Exception as e:
|
| 264 |
-
return jsonify({'success': False, 'error': str(e)})
|
| 265 |
-
|
| 266 |
@app.route('/booking/<booking_id>')
|
| 267 |
def booking_confirmation(booking_id):
|
| 268 |
booking = bookings.get(booking_id)
|
|
@@ -277,10 +287,7 @@ def check_availability():
|
|
| 277 |
visit_date = data.get('visit_date')
|
| 278 |
time_slot = data.get('time_slot')
|
| 279 |
|
| 280 |
-
|
| 281 |
-
capacity = 50 # Maximum visitors per slot
|
| 282 |
-
|
| 283 |
-
# Count existing bookings for this slot
|
| 284 |
booked_count = sum(
|
| 285 |
1 for booking in bookings.values()
|
| 286 |
if (booking['museum_id'] == museum_id and
|
|
@@ -296,11 +303,6 @@ def check_availability():
|
|
| 296 |
'capacity': capacity
|
| 297 |
})
|
| 298 |
|
| 299 |
-
@app.route('/api/museums')
|
| 300 |
-
def get_museums():
|
| 301 |
-
return jsonify(MUSEUMS)
|
| 302 |
-
|
| 303 |
-
# Chatbot API endpoints
|
| 304 |
@app.route('/api/chatbot/start', methods=['POST'])
|
| 305 |
def chatbot_start():
|
| 306 |
return jsonify(CHATBOT_RESPONSES['welcome'])
|
|
@@ -313,7 +315,6 @@ def chatbot_response():
|
|
| 313 |
if user_input in CHATBOT_RESPONSES:
|
| 314 |
response = CHATBOT_RESPONSES[user_input]
|
| 315 |
|
| 316 |
-
# Add museum details for specific responses
|
| 317 |
if user_input.endswith('_details'):
|
| 318 |
museum_id = user_input.replace('_details', '_museum')
|
| 319 |
if museum_id in MUSEUMS:
|
|
@@ -322,10 +323,23 @@ def chatbot_response():
|
|
| 322 |
"message": f"๐๏ธ {museum['name']}\nโญ Rating: {museum['rating']}/5\n๐ Location: {museum['location']}\n๐ฐ Price: โน{museum['price']}\nโฐ Timings: {museum['timings']}\n๐ซ Closed: {museum['closed_on']}\n\n{museum['description']}",
|
| 323 |
"options": [
|
| 324 |
{"text": "๐ซ Book Tickets", "value": museum_id},
|
|
|
|
| 325 |
{"text": "๐ Back to Museums", "value": "best_museums"},
|
| 326 |
{"text": "๐ Main Menu", "value": "back"}
|
| 327 |
]
|
| 328 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
|
| 330 |
return jsonify(response)
|
| 331 |
else:
|
|
@@ -334,9 +348,5 @@ def chatbot_response():
|
|
| 334 |
"options": CHATBOT_RESPONSES['welcome']['options']
|
| 335 |
})
|
| 336 |
|
| 337 |
-
@app.route('/health')
|
| 338 |
-
def health_check():
|
| 339 |
-
return jsonify({'status': 'healthy', 'timestamp': datetime.now().isoformat()})
|
| 340 |
-
|
| 341 |
if __name__ == '__main__':
|
| 342 |
app.run(debug=False, host='0.0.0.0', port=7860)
|
|
|
|
| 3 |
import json
|
| 4 |
import os
|
| 5 |
import uuid
|
| 6 |
+
import qrcode
|
| 7 |
+
import io
|
| 8 |
+
import base64
|
| 9 |
|
| 10 |
app = Flask(__name__)
|
| 11 |
app.secret_key = os.environ.get('SECRET_KEY', 'dev-secret-key')
|
| 12 |
app.config['SESSION_TYPE'] = 'filesystem'
|
| 13 |
|
| 14 |
+
# Sample data for Indian museums with coordinates
|
| 15 |
MUSEUMS = {
|
| 16 |
"national_museum": {
|
| 17 |
"id": "national_museum",
|
|
|
|
| 24 |
"timings": "10:00 AM - 6:00 PM",
|
| 25 |
"closed_on": "Monday",
|
| 26 |
"best_for": ["History", "Archaeology", "Art"],
|
| 27 |
+
"rating": 4.5,
|
| 28 |
+
"coordinates": {"lat": 28.6129, "lng": 77.2295},
|
| 29 |
+
"address": "Janpath Road, Rajpath Area, New Delhi, Delhi 110011",
|
| 30 |
+
"map_url": "https://maps.google.com/?q=National+Museum+New+Delhi"
|
| 31 |
},
|
| 32 |
"indian_museum": {
|
| 33 |
"id": "indian_museum",
|
|
|
|
| 40 |
"timings": "10:00 AM - 5:00 PM",
|
| 41 |
"closed_on": "Monday",
|
| 42 |
"best_for": ["Ancient History", "Natural History", "Art"],
|
| 43 |
+
"rating": 4.3,
|
| 44 |
+
"coordinates": {"lat": 22.5583, "lng": 88.3508},
|
| 45 |
+
"address": "27, Jawaharlal Nehru Rd, Park Street, Kolkata, West Bengal 700016",
|
| 46 |
+
"map_url": "https://maps.google.com/?q=Indian+Museum+Kolkata"
|
| 47 |
},
|
| 48 |
"chhatrapati_museum": {
|
| 49 |
"id": "chhatrapati_museum",
|
|
|
|
| 56 |
"timings": "10:15 AM - 6:00 PM",
|
| 57 |
"closed_on": "Monday",
|
| 58 |
"best_for": ["Architecture", "Sculptures", "Paintings"],
|
| 59 |
+
"rating": 4.7,
|
| 60 |
+
"coordinates": {"lat": 18.9260, "lng": 72.8320},
|
| 61 |
+
"address": "159-161, Mahatma Gandhi Road, Fort, Mumbai, Maharashtra 400023",
|
| 62 |
+
"map_url": "https://maps.google.com/?q=Chhatrapati+Shivaji+Maharaj+Vastu+Sangrahalaya+Mumbai"
|
| 63 |
},
|
| 64 |
"salar_jung": {
|
| 65 |
"id": "salar_jung",
|
|
|
|
| 72 |
"timings": "10:00 AM - 5:00 PM",
|
| 73 |
"closed_on": "Friday",
|
| 74 |
"best_for": ["Personal Collections", "Artifacts", "Manuscripts"],
|
| 75 |
+
"rating": 4.4,
|
| 76 |
+
"coordinates": {"lat": 17.3716, "lng": 78.4805},
|
| 77 |
+
"address": "Salar Jung Road, Near Minar Function Hall, Hyderabad, Telangana 500002",
|
| 78 |
+
"map_url": "https://maps.google.com/?q=Salar+Jung+Museum+Hyderabad"
|
| 79 |
}
|
| 80 |
}
|
| 81 |
|
|
|
|
| 99 |
{"text": "๐ Language Support", "value": "languages"},
|
| 100 |
{"text": "๐ฐ Pricing Info", "value": "pricing"},
|
| 101 |
{"text": "โฐ Timings", "value": "timings"},
|
| 102 |
+
{"text": "๐ Museum Locations", "value": "locations"},
|
| 103 |
{"text": "โ General Help", "value": "help"}
|
| 104 |
]
|
| 105 |
},
|
|
|
|
| 150 |
{"text": "๐ Back to Main Menu", "value": "back"}
|
| 151 |
]
|
| 152 |
},
|
| 153 |
+
"locations": {
|
| 154 |
+
"message": "Here are the museum locations across India:",
|
| 155 |
+
"options": [
|
| 156 |
+
{"text": "๐ National Museum - Delhi", "value": "national_location"},
|
| 157 |
+
{"text": "๐ Indian Museum - Kolkata", "value": "indian_location"},
|
| 158 |
+
{"text": "๐ Chhatrapati Museum - Mumbai", "value": "chhatrapati_location"},
|
| 159 |
+
{"text": "๐ Salar Jung Museum - Hyderabad", "value": "salarjung_location"},
|
| 160 |
+
{"text": "๐ Back to Main Menu", "value": "back"}
|
| 161 |
+
]
|
| 162 |
+
},
|
| 163 |
"help": {
|
| 164 |
+
"message": "I can help you with: ticket booking, museum information, pricing, timings, locations, and language support. What would you like to know?",
|
| 165 |
"options": [
|
| 166 |
{"text": "๐ซ Book Tickets", "value": "book_tickets"},
|
| 167 |
{"text": "๐๏ธ Museum Info", "value": "best_museums"},
|
| 168 |
+
{"text": "๐ Locations", "value": "locations"},
|
| 169 |
{"text": "๐ Back to Main Menu", "value": "back"}
|
| 170 |
]
|
| 171 |
}
|
| 172 |
}
|
| 173 |
|
| 174 |
+
# Store bookings
|
| 175 |
bookings = {}
|
|
|
|
| 176 |
|
| 177 |
+
def generate_qr_code(data):
|
| 178 |
+
"""Generate QR code as base64 string"""
|
| 179 |
+
qr = qrcode.QRCode(
|
| 180 |
+
version=1,
|
| 181 |
+
error_correction=qrcode.constants.ERROR_CORRECT_L,
|
| 182 |
+
box_size=10,
|
| 183 |
+
border=4,
|
| 184 |
+
)
|
| 185 |
+
qr.add_data(data)
|
| 186 |
+
qr.make(fit=True)
|
| 187 |
+
|
| 188 |
+
img = qr.make_image(fill_color="black", back_color="white")
|
| 189 |
+
buffer = io.BytesIO()
|
| 190 |
+
img.save(buffer, format="PNG")
|
| 191 |
+
buffer.seek(0)
|
| 192 |
+
|
| 193 |
+
img_str = base64.b64encode(buffer.getvalue()).decode()
|
| 194 |
+
return f"data:image/png;base64,{img_str}"
|
| 195 |
|
| 196 |
@app.route('/')
|
| 197 |
def home():
|
| 198 |
+
return render_template('index.html')
|
| 199 |
|
| 200 |
@app.route('/museums')
|
| 201 |
def museums():
|
| 202 |
+
return render_template('museums.html', museums=MUSEUMS)
|
| 203 |
|
| 204 |
@app.route('/museum/<museum_id>')
|
| 205 |
def museum_detail(museum_id):
|
|
|
|
| 207 |
if not museum:
|
| 208 |
return redirect(url_for('museums'))
|
| 209 |
|
|
|
|
| 210 |
current_date = datetime.now().strftime('%Y-%m-%d')
|
| 211 |
+
return render_template('booking.html', museum=museum, time_slots=TIME_SLOTS, now=current_date)
|
| 212 |
|
| 213 |
+
@app.route('/api/book', methods=['POST'])
|
| 214 |
+
def book_ticket():
|
| 215 |
try:
|
| 216 |
data = request.get_json()
|
|
|
|
|
|
|
| 217 |
|
| 218 |
+
required_fields = ['museum_id', 'visit_date', 'time_slot', 'visitors', 'name', 'email', 'phone']
|
| 219 |
+
for field in required_fields:
|
| 220 |
+
if field not in data or not data[field]:
|
| 221 |
+
return jsonify({'success': False, 'error': f'Missing field: {field}'})
|
| 222 |
+
|
| 223 |
+
museum_id = data['museum_id']
|
| 224 |
if museum_id not in MUSEUMS:
|
| 225 |
return jsonify({'success': False, 'error': 'Invalid museum'})
|
| 226 |
|
| 227 |
+
booking_id = str(uuid.uuid4())[:8].upper()
|
| 228 |
museum = MUSEUMS[museum_id]
|
| 229 |
+
total_amount = museum['price'] * int(data['visitors'])
|
| 230 |
+
|
| 231 |
+
# Generate QR code data
|
| 232 |
+
qr_data = f"""
|
| 233 |
+
Museum Ticket
|
| 234 |
+
Booking ID: {booking_id}
|
| 235 |
+
Museum: {museum['name']}
|
| 236 |
+
Date: {data['visit_date']}
|
| 237 |
+
Time: {data['time_slot']}
|
| 238 |
+
Visitors: {data['visitors']}
|
| 239 |
+
Total: โน{total_amount}
|
| 240 |
+
Name: {data['name']}
|
| 241 |
+
""".strip()
|
| 242 |
|
| 243 |
+
qr_code = generate_qr_code(qr_data)
|
|
|
|
| 244 |
|
| 245 |
+
booking = {
|
| 246 |
+
'booking_id': booking_id,
|
| 247 |
'museum_id': museum_id,
|
| 248 |
+
'museum_name': museum['name'],
|
| 249 |
+
'visit_date': data['visit_date'],
|
| 250 |
+
'time_slot': data['time_slot'],
|
| 251 |
+
'visitors': int(data['visitors']),
|
| 252 |
+
'total_amount': total_amount,
|
| 253 |
+
'customer_name': data['name'],
|
| 254 |
+
'customer_email': data['email'],
|
| 255 |
+
'customer_phone': data['phone'],
|
| 256 |
+
'language': data.get('language', 'English'),
|
| 257 |
+
'booking_date': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
| 258 |
+
'status': 'confirmed',
|
| 259 |
+
'qr_code': qr_code,
|
| 260 |
+
'museum_address': museum.get('address', ''),
|
| 261 |
+
'museum_coordinates': museum.get('coordinates', {}),
|
| 262 |
+
'map_url': museum.get('map_url', '')
|
| 263 |
}
|
| 264 |
|
| 265 |
+
bookings[booking_id] = booking
|
| 266 |
+
|
| 267 |
return jsonify({
|
| 268 |
'success': True,
|
| 269 |
+
'booking_id': booking_id,
|
| 270 |
+
'booking': booking
|
|
|
|
|
|
|
| 271 |
})
|
| 272 |
|
| 273 |
except Exception as e:
|
| 274 |
return jsonify({'success': False, 'error': str(e)})
|
| 275 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
@app.route('/booking/<booking_id>')
|
| 277 |
def booking_confirmation(booking_id):
|
| 278 |
booking = bookings.get(booking_id)
|
|
|
|
| 287 |
visit_date = data.get('visit_date')
|
| 288 |
time_slot = data.get('time_slot')
|
| 289 |
|
| 290 |
+
capacity = 50
|
|
|
|
|
|
|
|
|
|
| 291 |
booked_count = sum(
|
| 292 |
1 for booking in bookings.values()
|
| 293 |
if (booking['museum_id'] == museum_id and
|
|
|
|
| 303 |
'capacity': capacity
|
| 304 |
})
|
| 305 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
@app.route('/api/chatbot/start', methods=['POST'])
|
| 307 |
def chatbot_start():
|
| 308 |
return jsonify(CHATBOT_RESPONSES['welcome'])
|
|
|
|
| 315 |
if user_input in CHATBOT_RESPONSES:
|
| 316 |
response = CHATBOT_RESPONSES[user_input]
|
| 317 |
|
|
|
|
| 318 |
if user_input.endswith('_details'):
|
| 319 |
museum_id = user_input.replace('_details', '_museum')
|
| 320 |
if museum_id in MUSEUMS:
|
|
|
|
| 323 |
"message": f"๐๏ธ {museum['name']}\nโญ Rating: {museum['rating']}/5\n๐ Location: {museum['location']}\n๐ฐ Price: โน{museum['price']}\nโฐ Timings: {museum['timings']}\n๐ซ Closed: {museum['closed_on']}\n\n{museum['description']}",
|
| 324 |
"options": [
|
| 325 |
{"text": "๐ซ Book Tickets", "value": museum_id},
|
| 326 |
+
{"text": "๐ View Location", "value": f"{museum_id}_location"},
|
| 327 |
{"text": "๐ Back to Museums", "value": "best_museums"},
|
| 328 |
{"text": "๐ Main Menu", "value": "back"}
|
| 329 |
]
|
| 330 |
}
|
| 331 |
+
elif user_input.endswith('_location'):
|
| 332 |
+
museum_id = user_input.replace('_location', '_museum')
|
| 333 |
+
if museum_id in MUSEUMS:
|
| 334 |
+
museum = MUSEUMS[museum_id]
|
| 335 |
+
response = {
|
| 336 |
+
"message": f"๐ {museum['name']}\n๐ {museum['address']}\n\n๐บ๏ธ Map: {museum['map_url']}",
|
| 337 |
+
"options": [
|
| 338 |
+
{"text": "๐ซ Book Tickets", "value": museum_id},
|
| 339 |
+
{"text": "๐ Back to Locations", "value": "locations"},
|
| 340 |
+
{"text": "๐ Main Menu", "value": "back"}
|
| 341 |
+
]
|
| 342 |
+
}
|
| 343 |
|
| 344 |
return jsonify(response)
|
| 345 |
else:
|
|
|
|
| 348 |
"options": CHATBOT_RESPONSES['welcome']['options']
|
| 349 |
})
|
| 350 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
if __name__ == '__main__':
|
| 352 |
app.run(debug=False, host='0.0.0.0', port=7860)
|