Pijush2023 commited on
Commit
7a539c5
·
verified ·
1 Parent(s): e9535d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -1
app.py CHANGED
@@ -64,6 +64,69 @@ def get_current_time_and_date():
64
  current_time_and_date = get_current_time_and_date()
65
 
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  def fetch_local_events():
68
  api_key = os.environ['SERP_API']
69
  url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
@@ -78,9 +141,10 @@ def fetch_local_events():
78
  color: #333;
79
  border-collapse: collapse;
80
  width: 100%;
 
81
  }
82
  th, td {
83
- border: 1px solid #ddd;
84
  padding: 8px;
85
  }
86
  th {
@@ -128,6 +192,8 @@ def fetch_local_events():
128
  return "<p>Failed to fetch local events</p>"
129
 
130
 
 
 
131
  def fetch_local_weather():
132
  try:
133
  api_key = os.environ['WEATHER_API']
 
64
  current_time_and_date = get_current_time_and_date()
65
 
66
 
67
+ # def fetch_local_events():
68
+ # api_key = os.environ['SERP_API']
69
+ # url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
70
+ # response = requests.get(url)
71
+ # if response.status_code == 200:
72
+ # events_results = response.json().get("events_results", [])
73
+ # events_html = """
74
+ # <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Events</h2>
75
+ # <style>
76
+ # table {
77
+ # font-family: 'Verdana', sans-serif;
78
+ # color: #333;
79
+ # border-collapse: collapse;
80
+ # width: 100%;
81
+ # }
82
+ # th, td {
83
+ # border: 1px solid #ddd;
84
+ # padding: 8px;
85
+ # }
86
+ # th {
87
+ # background-color: #f2f2f2;
88
+ # color: #333;
89
+ # text-align: left;
90
+ # }
91
+ # tr:hover {
92
+ # background-color: #f5f5f5;
93
+ # }
94
+ # .event-link {
95
+ # color: #1E90FF;
96
+ # text-decoration: none;
97
+ # }
98
+ # .event-link:hover {
99
+ # text-decoration: underline;
100
+ # }
101
+ # </style>
102
+ # <table>
103
+ # <tr>
104
+ # <th>Title</th>
105
+ # <th>Date and Time</th>
106
+ # <th>Location</th>
107
+ # </tr>
108
+ # """
109
+ # for event in events_results:
110
+ # title = event.get("title", "No title")
111
+ # date_info = event.get("date", {})
112
+ # date = f"{date_info.get('start_date', '')} {date_info.get('when', '')}".replace("{", "").replace("}", "")
113
+ # location = event.get("address", "No location")
114
+ # if isinstance(location, list):
115
+ # location = " ".join(location)
116
+ # location = location.replace("[", "").replace("]", "")
117
+ # link = event.get("link", "#")
118
+ # events_html += f"""
119
+ # <tr>
120
+ # <td><a class='event-link' href='{link}' target='_blank'>{title}</a></td>
121
+ # <td>{date}</td>
122
+ # <td>{location}</td>
123
+ # </tr>
124
+ # """
125
+ # events_html += "</table>"
126
+ # return events_html
127
+ # else:
128
+ # return "<p>Failed to fetch local events</p>"
129
+
130
  def fetch_local_events():
131
  api_key = os.environ['SERP_API']
132
  url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
 
141
  color: #333;
142
  border-collapse: collapse;
143
  width: 100%;
144
+ border: 1px solid #fff;
145
  }
146
  th, td {
147
+ border: 1px solid #fff;
148
  padding: 8px;
149
  }
150
  th {
 
192
  return "<p>Failed to fetch local events</p>"
193
 
194
 
195
+
196
+
197
  def fetch_local_weather():
198
  try:
199
  api_key = os.environ['WEATHER_API']