diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 9b28bb2..855af14 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -9,6 +9,6 @@ libc = "0.2.155" serde = { version = "1.0.202", features = ["derive"] } tempfile = "3.10.1" tokio = { version = "1.37.0", features = ["rt-multi-thread"] } -tower-http = { version = "0.5.2", features = ["trace"] } +tower-http = { version = "0.5.2", features = ["trace", "cors"] } tracing = "0.1.40" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } diff --git a/backend/src/main.rs b/backend/src/main.rs index 23fbf04..434cdc3 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -9,6 +9,7 @@ use axum::{ }; use serde::{Deserialize, Serialize}; use tower_http::trace::TraceLayer; +use tower_http::cors::CorsLayer; use tracing::info_span; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; @@ -65,7 +66,9 @@ async fn main() { .with(tracing_subscriber::fmt::layer()) .init(); - let app = Router::new().route("/v1/exec", post(exec)).layer( + let app = Router::new().route("/v1/exec", post(exec)) + .layer(CorsLayer::permissive()) + .layer( TraceLayer::new_for_http().make_span_with(|request: &Request<_>| { let matched_path = request .extensions() diff --git a/backend/src/sandbox.rs b/backend/src/sandbox.rs index f4d444e..66df384 100644 --- a/backend/src/sandbox.rs +++ b/backend/src/sandbox.rs @@ -27,7 +27,7 @@ const STATIC_ARGS: &[&str] = &[ const HARE_COMMAND: &str = "/usr/local/bin/hare"; /// Default command timeout in seconds. -const DEFAULT_TIMEOUT: u32 = 10; +const DEFAULT_TIMEOUT: u32 = 30; fn passwd_files(uid: u32, gid: u32) -> (NamedTempFile, NamedTempFile, Vec) { let uid = uid.to_string(); @@ -96,6 +96,7 @@ fn shared_app_dir() -> (TempDir, Vec) { fn command(app_file: &str) -> Vec { vec![ + "/usr/bin/timeout".to_string(), DEFAULT_TIMEOUT.to_string(), HARE_COMMAND.to_string(), "run".to_string(), app_file.to_string(), diff --git a/frontend/code.html b/frontend/code.html index a820e85..d1805a1 100644 --- a/frontend/code.html +++ b/frontend/code.html @@ -46,13 +46,29 @@ - +
-
msg = "Hello, World!"
-print(msg)
+

+use fmt;
+use time;
+
+export fn main() void = {
+        const greetings = [
+                "Hello, world!",
+                "¡Hola Mundo!",
+                "Γειά σου Κόσμε!",
+                "Привіт, світ!",
+                "こんにちは世界!",
+        ];
+        for (let i = 0z; i < len(greetings); i+= 1) {
+                fmt::println(greetings[i])!;
+                time::sleep(1 * time::SECOND);
+        };
+};
+
- +