aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2017-01-04 00:07:20 -0800
committerbnewbold <bnewbold@robocracy.org>2017-01-04 00:07:20 -0800
commitaf3af9dd11f3573cf96c9b14b8566b345aad5e8e (patch)
treea7702f0874a9ddbbec9d787a895332d4cedf4b32 /src/bin
parent351a2e81fdc50a16d44efd25d1516de7afb08b11 (diff)
downloadmodelthing-af3af9dd11f3573cf96c9b14b8566b345aad5e8e.tar.gz
modelthing-af3af9dd11f3573cf96c9b14b8566b345aad5e8e.zip
add /raw/ model download
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;