Added updating blockchains button
This commit is contained in:
11
src/main.rs
11
src/main.rs
@@ -1,6 +1,6 @@
|
||||
#[macro_use] extern crate rocket;
|
||||
use rocket_dyn_templates::{context, Template};
|
||||
use blockchain_time::{BlockchainInfo, BlockchainSupported};
|
||||
use blockchain_time::{BlockchainInfo, BlockchainSupported, update_all_blockheights};
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> Template {
|
||||
@@ -16,8 +16,15 @@ fn index() -> Template {
|
||||
Template::render("index", context)
|
||||
}
|
||||
|
||||
#[get("/update_blockchains")]
|
||||
fn update_blockchains() -> Template {
|
||||
update_all_blockheights();
|
||||
Template::render("update_complete", context!{})
|
||||
}
|
||||
|
||||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
rocket::build().mount("/", routes![index])
|
||||
rocket::build().mount("/", routes![index, update_blockchains])
|
||||
// .mount("/update_blockchains", routes![update_blockchains])
|
||||
.attach(Template::fairing())
|
||||
}
|
||||
|
||||
@@ -41,9 +41,7 @@
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
<form action="update_blockchains">
|
||||
<input type="submit" value="Update Blockchain Information" />
|
||||
</form>
|
||||
<a href="update_blockchains">Update Blockchain Information</a>
|
||||
<p>Pressing the above button might take some time... or it might crash the appliaction...
|
||||
or it'll do what you want... you won't know till you press it.</p>
|
||||
|
||||
|
||||
7
templates/update_complete.html.tera
Normal file
7
templates/update_complete.html.tera
Normal file
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
If you're seeing this, it probably worked. Go back <a href="/">here</a> to check.
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user