aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/mt-webface.rs9
1 files changed, 9 insertions, 0 deletions
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/<namespace:string>/", "model_list", model_list);
app.register_template("model_view.html");
app.get("/m/<namespace:string>/<model_slug:string>/", "model_view", model_view);
+ app.get("/m/<namespace:string>/<model_slug:string>/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;