removed axios / vuejs stuff
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul 2023-07-13 22:25:21 +02:00
parent 6c77212eba
commit 2daa8927d1
8 changed files with 33 additions and 72 deletions

View File

@ -22,6 +22,7 @@ func GetStatic(staticfiles *embed.FS, c echo.Context) (err error) {
} else if strings.HasSuffix(name, ".css") { } else if strings.HasSuffix(name, ".css") {
c.Response().Header().Set(echo.HeaderContentType, "text/css") c.Response().Header().Set(echo.HeaderContentType, "text/css")
} }
c.Response().Header().Add(echo.HeaderCacheControl, "max-age=172800")
return c.String(http.StatusOK, string(content)) return c.String(http.StatusOK, string(content))
} }

View File

@ -15,6 +15,7 @@ func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Con
if strings.HasSuffix(name, ".html") { if strings.HasSuffix(name, ".html") {
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTMLCharsetUTF8) c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTMLCharsetUTF8)
} }
c.Response().Header().Add(echo.HeaderCacheControl, "max-age=172800")
return t.templates.ExecuteTemplate(w, name, data) return t.templates.ExecuteTemplate(w, name, data)
} }
@ -38,29 +39,6 @@ func BuildTemplates(templatefiles *embed.FS) (builttemplates *Template, err erro
return return
} }
/*
// BuildTemplatesDir converts packr packages to html/template
func BuildTemplatesDir(dir string) (builttemplates *Template, err error) {
tmpl := template.New("templates")
err = pkger.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
freader, _ := pkger.Open(path)
tmplContent, err := ioutil.ReadAll(freader)
tmpl.New(info.Name()).Parse(string(tmplContent))
fmt.Println(info.Name(), tmplContent)
return err
})
builttemplates = &Template{
templates: tmpl,
}
return
}*/
// Template is a template struct // Template is a template struct
type Template struct { type Template struct {
templates *template.Template templates *template.Template

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,29 +1,25 @@
var vue = new Vue({ function main() {
el: '#dip_main_div', let dip_ip = document.getElementById("dip_ip");
let dip_hostname = document.getElementById("dip_hostname");
let dip_city = document.getElementById("dip_city");
let dip_as_number = document.getElementById("dip_as_number");
let dip_as_org = document.getElementById("dip_as_org");
data () {
return {
title: "Public IP Address service",
dip: {"ip": null,
"hostname": null,
"city": null,
"country": null},
}
},
mounted () {
var ip = ""; var ip = "";
if (window.location.pathname.length > 4) { if (window.location.pathname.length > 4) {
ip = window.location.pathname.split("/")[1]; ip = window.location.pathname.split("/")[1];
console.log(ip); console.log(ip);
} }
axios.get(`/json/${ip}`)
.then(response => { fetch(`/json/${ip}`).then((response) => {
this.dip = response.data response.json().then((res) => {
}) dip_ip.innerHTML = res["ip"];
.catch(err => { dip_hostname.innerHTML = res["hostname"];
// Manage the state of the application if the request dip_city.innerHTML = res["city"];
// has failed dip_as_number.innerHTML = res["as"]["number"];
dip_as_org.innerHTML = res["as"]["org"];
});
}); });
} }
});
main();

File diff suppressed because one or more lines are too long

View File

@ -10,6 +10,4 @@
<script src="static/js/uikit.min.js"></script> <script src="static/js/uikit.min.js"></script>
<script src="static/js/uikit-icons.min.js"></script> <script src="static/js/uikit-icons.min.js"></script>
<script src="static/js/axios.min.js"></script>
<script src="static/js/vue.min.js"></script>
</head> </head>

View File

@ -8,29 +8,27 @@
<caption>IP informations</caption> <caption>IP informations</caption>
<tr> <tr>
<td>IP</td> <td>IP</td>
<td>{{ "{{" }} dip.ip {{ "}}" }}</td> <td id="dip_ip"></td>
</tr> </tr>
<tr> <tr>
<td>Reverse DNS</td> <td>Reverse DNS</td>
<td>{{ "{{" }} dip.hostname {{ "}}" }}</td> <td id="dip_hostname"></td>
</tr> </tr>
<tr> <tr>
<td>City</td> <td>City</td>
<td>{{ "{{" }} dip.city {{ "}}" }}</td> <td id="dip_city"></td>
</tr> </tr>
<tr> <tr>
<td>Country</td> <td>Country</td>
<td>{{ "{{" }} dip.country {{ "}}" }}</td> <td id="dip_country"></td>
</tr> </tr>
<tr> <tr>
<td>AS number</td> <td>AS number</td>
<td>{{ "{{" }} dip.as.number {{ "}}" }}</td> <td id="dip_as_number"></td>
</tr> </tr>
<tr> <tr>
<td>AS name</td> <td>AS name</td>
<td> <td id="dip_as_org"></td>
{{ "{{" }} dip.as.org {{ "}}" }}
</td>
</tr> </tr>
</div> </div>
{{ template "footer_js.html" .}} {{ template "footer_js.html" .}}