Webapp actually does something

This commit is contained in:
greg 2017-10-02 00:15:39 -07:00
parent 9071846df3
commit 7430aebe63

View File

@ -1,7 +1,8 @@
use rocket; use rocket;
use rocket::response::NamedFile; use rocket::response::NamedFile;
use rocket_contrib::Json; use rocket_contrib::Json;
use schala_lang;
use language::{ProgrammingLanguageInterface, EvalOptions};
#[get("/")] #[get("/")]
fn index() -> Result<NamedFile, ()> { fn index() -> Result<NamedFile, ()> {
@ -25,9 +26,9 @@ struct Output {
#[post("/input", format = "application/json", data = "<input>")] #[post("/input", format = "application/json", data = "<input>")]
fn interpreter_input(input: Json<Input>) -> Json<Output> { fn interpreter_input(input: Json<Input>) -> Json<Output> {
println!("INPUT {:?}", input); let mut schala = schala_lang::Schala::new();
let output = Output { text: "test interpreter output".to_string() }; let code_output = schala.evaluate_in_repl(&input.source, &EvalOptions::default());
Json(output) Json(Output { text: code_output.to_string() })
} }
pub fn web_main() { pub fn web_main() {