Initial commit
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
#[macro_use] extern crate rocket;
|
||||
|
||||
use rocket::form::Form;
|
||||
use rocket::form::FromForm;
|
||||
use rocket_dyn_templates::{Template, context};
|
||||
|
||||
#[derive(FromForm)]
|
||||
struct LoginData {
|
||||
username: String,
|
||||
password: String,
|
||||
}
|
||||
|
||||
#[post("/login", data = "<login_data>")]
|
||||
fn login(login_data: Form<LoginData>) -> Template {
|
||||
let correct_username = "user";
|
||||
let correct_password = "password";
|
||||
|
||||
let message = if login_data.username == correct_username && login_data.password == correct_password {
|
||||
// On successful login, you can perform actions here like creating directories.
|
||||
println!("Login successful: performing server-side actions.");
|
||||
|
||||
"Login successful! Directories have been created."
|
||||
} else {
|
||||
"Invalid username or password."
|
||||
};
|
||||
|
||||
Template::render("result", context! { message })
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> Template {
|
||||
Template::render("index", context! {})
|
||||
}
|
||||
|
||||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
rocket::build()
|
||||
.mount("/", routes![index, login])
|
||||
.attach(Template::fairing())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user