-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
49 lines (42 loc) · 1.61 KB
/
Copy pathapp.py
File metadata and controls
49 lines (42 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import requests
import json
class TrainStatusTracker:
def __init__(self):
# Demo API endpoint placeholder
self.api_url = "https://api.example.com/train-status"
def fetch_train_status(self, train_number):
"""
Simulated API call for live train status.
Replace this logic with real API integration if available.
"""
print(f"Fetching live status for Train No: {train_number}")
# Simulated response data
response_data = {
"train_number": train_number,
"train_name": "Mumbai Express",
"source": "CSMT",
"destination": "Thane",
"current_station": "Dadar",
"next_station": "Kurla",
"delay": "0 Minutes",
"status": "Running On Time"
}
return response_data
def display_status(self, data):
print("\n===== LIVE TRAIN STATUS =====")
print(f"Train Number : {data['train_number']}")
print(f"Train Name : {data['train_name']}")
print(f"Source : {data['source']}")
print(f"Destination : {data['destination']}")
print(f"Current Station: {data['current_station']}")
print(f"Next Station : {data['next_station']}")
print(f"Delay : {data['delay']}")
print(f"Status : {data['status']}")
print("==============================")
def main():
tracker = TrainStatusTracker()
train_number = input("Enter Train Number: ")
status = tracker.fetch_train_status(train_number)
tracker.display_status(status)
if __name__ == "__main__":
main()