Skip to content

Commit 497fc94

Browse files
author
Michael William Le Nguyen
committed
Add weather display
1 parent 241ee01 commit 497fc94

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/App.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<div class="col-md-5">
88
<div>
99
<h1>Weather <span class="material-icons">cloud</span></h1>
10+
<img :src="'http://openweathermap.org/img/w/' + weather.icon + '.png'" style="width: 25%;">
11+
<h2>{{ weather.temp + '°F' }}</h2>
12+
<h2>{{ weather.description }}</h2>
1013
</div>
1114
<div>
1215
<h1>Shuttles <span class="material-icons">airport_shuttle</span></h1>
@@ -42,11 +45,25 @@ export default class App extends Vue {
4245
private error: boolean = false
4346
private info: Map<string, { prediction: string, title: string }> = new Map()
4447
private time: string = ''
48+
private weather: { description: string, icon: string, temp: number } = { description: '', icon: '', temp: 0 }
49+
private weatherError: boolean = false
4550
4651
private mounted (): void {
4752
setInterval(() => {
4853
this.time = new Date().toLocaleString()
4954
}, 1000)
55+
fetch('weather.py').then((data) => {
56+
return data.json()
57+
}).then((data) => {
58+
this.weather = {
59+
description: data.weather[0].description,
60+
icon: data.weather[0].icon,
61+
temp: Math.floor(data.main.temp)
62+
}
63+
}).catch((error) => {
64+
console.log(error)
65+
this.weatherError = true
66+
})
5067
5168
fetch('http://webservices.nextbus.com/service/publicJSONFeed?command=predictionsForMultiStops&a=mit' +
5269
'&stops=tech|tangwest&stops=saferidecampshut|tangwest').then((data) => {

0 commit comments

Comments
 (0)