A tiny bit more work on the webapp
This commit is contained in:
parent
88209d370d
commit
7ac5846282
@ -18,4 +18,5 @@ serde_derive = "1.0.15"
|
||||
serde_json = "1.0.3"
|
||||
rocket = "*"
|
||||
rocket_codegen = "*"
|
||||
rocket_contrib = "*"
|
||||
|
||||
|
@ -12,6 +12,7 @@ extern crate maplit;
|
||||
extern crate serde_derive;
|
||||
extern crate serde_json;
|
||||
extern crate rocket;
|
||||
extern crate rocket_contrib;
|
||||
|
||||
use std::path::Path;
|
||||
use std::fs::File;
|
||||
|
@ -1,12 +1,29 @@
|
||||
use rocket;
|
||||
|
||||
use rocket::response::NamedFile;
|
||||
use rocket_contrib::Json;
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> Result<NamedFile, ()> {
|
||||
NamedFile::open("static/index.html").map_err(|_| ())
|
||||
}
|
||||
|
||||
pub fn web_main() {
|
||||
rocket::ignite().mount("/", routes![index]).launch();
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct Input {
|
||||
source: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct Output {
|
||||
text: String,
|
||||
}
|
||||
|
||||
#[post("/input", format = "application/json", data = "<input>")]
|
||||
fn interpreter_input(input: Json<Input>) -> Json<Output> {
|
||||
let output = Output { text: "test interpreter output".to_string() };
|
||||
Json(output)
|
||||
}
|
||||
|
||||
pub fn web_main() {
|
||||
rocket::ignite().mount("/", routes![index, interpreter_input]).launch();
|
||||
}
|
||||
|
@ -3,6 +3,10 @@
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
Test
|
||||
Type your source code into here:
|
||||
<textarea class="code-input">
|
||||
|
||||
</textarea>
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
3
static/main.js
Normal file
3
static/main.js
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
console.log("YOLO");
|
Loading…
Reference in New Issue
Block a user