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;
|
#[macro_use] extern crate rocket;
|
||||||
use rocket_dyn_templates::{context, Template};
|
use rocket_dyn_templates::{context, Template};
|
||||||
use blockchain_time::{BlockchainInfo, BlockchainSupported};
|
use blockchain_time::{BlockchainInfo, BlockchainSupported, update_all_blockheights};
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
fn index() -> Template {
|
fn index() -> Template {
|
||||||
@@ -16,8 +16,15 @@ fn index() -> Template {
|
|||||||
Template::render("index", context)
|
Template::render("index", context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/update_blockchains")]
|
||||||
|
fn update_blockchains() -> Template {
|
||||||
|
update_all_blockheights();
|
||||||
|
Template::render("update_complete", context!{})
|
||||||
|
}
|
||||||
|
|
||||||
#[launch]
|
#[launch]
|
||||||
fn rocket() -> _ {
|
fn rocket() -> _ {
|
||||||
rocket::build().mount("/", routes![index])
|
rocket::build().mount("/", routes![index, update_blockchains])
|
||||||
|
// .mount("/update_blockchains", routes![update_blockchains])
|
||||||
.attach(Template::fairing())
|
.attach(Template::fairing())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,9 +41,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<form action="update_blockchains">
|
<a href="update_blockchains">Update Blockchain Information</a>
|
||||||
<input type="submit" value="Update Blockchain Information" />
|
|
||||||
</form>
|
|
||||||
<p>Pressing the above button might take some time... or it might crash the appliaction...
|
<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>
|
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