From af3af9dd11f3573cf96c9b14b8566b345aad5e8e Mon Sep 17 00:00:00 2001 From: bnewbold Date: Wed, 4 Jan 2017 00:07:20 -0800 Subject: add /raw/ model download --- src/bin/mt-webface.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bin/mt-webface.rs b/src/bin/mt-webface.rs index 50179e1..ccf4660 100644 --- a/src/bin/mt-webface.rs +++ b/src/bin/mt-webface.rs @@ -69,6 +69,14 @@ fn model_view(r: &mut Request) -> PencilResult { } } +// Sends the modelica file +fn model_raw(r: &mut Request) -> PencilResult { + let namespace = r.view_args.get("namespace").unwrap(); + let model_slug = r.view_args.get("model_slug").unwrap(); + let model_path = Path::new(namespace).join(model_slug).to_string_lossy().to_string(); + pencil::helpers::send_from_directory(&model_path, "model.modelica", true) +} + fn page_not_found(_: HTTPError) -> PencilResult { let mut response = Response::from("404: Not Found"); response.status_code = 404; @@ -135,6 +143,7 @@ fn main() { app.get("/m//", "model_list", model_list); app.register_template("model_view.html"); app.get("/m///", "model_view", model_view); + app.get("/m///raw/", "model_raw", model_raw); let bind = matches.opt_str("bind").unwrap_or("127.0.0.1:5000".to_string()); let bind_str: &str = &bind; -- cgit v1.2.3