Main project #1

Merged
raul merged 33 commits from testing into main 2024-06-14 07:49:34 +02:00
3 changed files with 141 additions and 53 deletions
Showing only changes of commit 7ebc68a9a4 - Show all commits

View File

@ -49,31 +49,12 @@ type root struct {
// Probabilidad string `json:"#content"` // Probabilidad string `json:"#content"`
// Periodo string `json:"-periodo"` // Periodo string `json:"-periodo"`
// } `json:"prob_precipitacion"` // } `json:"prob_precipitacion"`
} `json:"dia"` } `json:"dia"`
} `json:"prediccion"` } `json:"prediccion"`
} `json:"root"` } `json:"root"`
} }
// func client() { func getJSON(codPostal string) (string, error) {
// jsonData, err := getJSON()
// if err != nil {
// log.Fatal(err)
// }
// textBytes := []byte(jsonData)
// aemetRequest := root{}
// err = json.Unmarshal(textBytes, &aemetRequest)
// if err != nil {
// log.Fatalf("Error occurred unmarshalling data: %v\n", err)
// }
//
// fmt.Println(aemetRequest.Base.Nombre)
// fmt.Println(aemetRequest.Base.Prediccion.Dia[0].Fecha)
// fmt.Printf("Temperatura máxima: %v°C\n", aemetRequest.Base.Prediccion.Dia[0].Temperatura.Maxima)
// fmt.Printf("Temperatura mínima: %v°C\n", aemetRequest.Base.Prediccion.Dia[0].Temperatura.Minima)
// }
func getJSON(codPostal string) (s string, err error) {
client := &http.Client{} client := &http.Client{}
req, err := http.NewRequest("GET", "https://www.aemet.es/xml/municipios/localidad_"+codPostal+".xml", nil) req, err := http.NewRequest("GET", "https://www.aemet.es/xml/municipios/localidad_"+codPostal+".xml", nil)
if err != nil { if err != nil {
@ -106,6 +87,7 @@ func getJSON(codPostal string) (s string, err error) {
// I am in tremendous pain after what I had to go through to get this damn thing working, // I am in tremendous pain after what I had to go through to get this damn thing working,
json, err := xj.Convert(xml, xj.WithNodes( json, err := xj.Convert(xml, xj.WithNodes(
xj.NodePlugin("root.prediccion.dia.estado_cielo", xj.ToArray()), xj.NodePlugin("root.prediccion.dia.estado_cielo", xj.ToArray()),
xj.NodePlugin("root.prediccion.dia.prob_precipitacion", xj.ToArray()),
)) ))
if err != nil { if err != nil {

View File

@ -9,20 +9,25 @@
</head> </head>
<body> <body>
<div class="container">
<div id="main">
<table border=1> <table border=1>
<th colspan="100%">{{ .Base.Nombre }}</th> <th colspan="100%">{{ .Base.Nombre }}</th>
<tr> <tr>
<td>Dia</td> <td>Dia</td>
{{ range .Base.Prediccion.Dia}} {{ range .Base.Prediccion.Dia}}
<td>{{ .Fecha }}</td> <td>{{ .Fecha }}</td>
{{ end }} {{ end }}
</tr> </tr>
<tr> <tr>
<td>Temp. Máxima</td> <td>Temp. Máxima</td>
{{ range .Base.Prediccion.Dia}} {{ range .Base.Prediccion.Dia}}
<td>{{ .Temperatura.Maxima }}</td> <td>{{ .Temperatura.Maxima }}</td>
{{ end }} {{ end }}
</tr> </tr>
<tr> <tr>
<td>Temp. Mínima</td> <td>Temp. Mínima</td>
{{ range .Base.Prediccion.Dia}} {{ range .Base.Prediccion.Dia}}
@ -42,8 +47,10 @@
</td> </td>
{{ end }} {{ end }}
</tr> </tr>
</table>
</table>
</div>
</div>
</body> </body>
</html> </html>

View File

@ -1,4 +1,103 @@
* {
font-family: arial;
}
table { table {
border: 1px solid black; border: 1px solid black;
border-collapse: collapse; border-collapse: collapse;
} }
table * {
text-align: center;
}
input {
margin-bottom: 10px;
}
#but {
background-color: #eee;
border: 2px black solid;
}
.centered {
text-align: center;
}
img {
text-align: center;
border: 2px solid #ff6e00;
border-radius: 50%;
padding: 1%;
}
button {
background-color: #eee;
border: 2px black solid;
margin-bottom: 10px;
}
#but:hover {
background-color: #ff6e00;
border: 2px black solid;
}
body {
background-color: #aaa;
}
h1 {
text-align: center;
bottom: 0%;
}
h3 {
text-align: center;
}
form {
text-align: center;
}
a {
color: #ff6e00;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
progress::-moz-progress-bar {
background-color: #ff6e00;
}
progress::-webkit-progress-value {
background-color: #ff6e00;
}
progress {
color: #ff6e00;
}
footer {
top: 100%;
}
#main {
background-color: #eee;
bottom: 100%;
height: 100%;
padding-left: 5%;
padding-right: 5%;
outline: solid 2px #ff6e00;
}
.container {
display: flex;
/* outline: solid 1px black; */
justify-content: center;
height: 100%;
max-width: 100%;
background-color: #aaa;
}