From 006fd7d41154493f9ce5a5376ccd210ab04bb7d1 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 19 Sep 2017 01:54:54 -0700 Subject: [PATCH] Trying webapp Note this doesn't work yet --- Cargo.toml | 2 ++ README.md | 4 ++++ src/main.rs | 10 ++++++++++ src/webapp.rs | 8 ++++++++ 4 files changed, 24 insertions(+) create mode 100644 src/webapp.rs diff --git a/Cargo.toml b/Cargo.toml index 4537b04..722f2ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,4 +16,6 @@ colored = "1.5" serde = "1.0.15" serde_derive = "1.0.15" serde_json = "1.0.3" +rocket = "*" +rocket_codegen = "*" diff --git a/README.md b/README.md index ac65c86..1ba59b0 100644 --- a/README.md +++ b/README.md @@ -58,3 +58,7 @@ http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-ma ### LLVM http://blog.ulysse.io/2016/07/03/llvm-getting-started.html + +###Rust resources +https://thefullsnack.com/en/rust-for-the-web.html +https://rocket.rs/guide/getting-started/ diff --git a/src/main.rs b/src/main.rs index ebb0eae..cd6295d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,6 +24,8 @@ mod robo_lang; mod language; use language::{ProgrammingLanguageInterface, EvalOptions, LLVMCodeString}; +mod webapp; + mod llvm_wrap; mod virtual_machine; @@ -69,6 +71,11 @@ fn main() { std::process::exit(0); } + if option_matches.opt_present("w") { + webapp::web_main(); + std::process::exit(0); + } + let language_names: Vec = languages.iter().map(|lang| {lang.get_language_name()}).collect(); let initial_index: usize = option_matches.opt_str("l") @@ -361,6 +368,9 @@ fn program_options() -> getopts::Options { options.optflag("a", "assembler", "Assemble file into bytecode"); + options.optflag("w", + "webapp", + "Start up web interpreter"); options } diff --git a/src/webapp.rs b/src/webapp.rs new file mode 100644 index 0000000..967d92f --- /dev/null +++ b/src/webapp.rs @@ -0,0 +1,8 @@ +#[get("/")] +fn index() -> &'static str { + "rocket test" +} + +fn web_main() { + rocket::ignite().mount("/", routes![index]).launch(); +}