get a tiny app workin'!
This commit is contained in:
@@ -3,18 +3,45 @@
|
||||
extern crate soda;
|
||||
|
||||
use soda::prelude::*;
|
||||
use css::*;
|
||||
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let page = PageBase("Test Page",
|
||||
let page = PageBase("Test Page",
|
||||
(
|
||||
Tag::Style((
|
||||
Rule(
|
||||
Select::Tag("div").and(Select::Class("red")).or(Select::Tag("span").and(Select::Class("red"))),
|
||||
Property::BackgroundColor("red")
|
||||
),
|
||||
Rule(
|
||||
Select::Class("bigger"),
|
||||
Property::FontSize(|st : &mut u32| {
|
||||
format!("{}px", *st + 10)
|
||||
})
|
||||
)
|
||||
)),
|
||||
Tag::Heading1("Hello, World!"),
|
||||
Tag::Paragraph("This is a test of Soda, an ultrafast composable frontend framework built in Rust!")
|
||||
Tag::Paragraph("This is a test of Soda, an ultrafast composable frontend framework built in Rust!"),
|
||||
Tag::Paragraph((
|
||||
"This page has been visited ",
|
||||
|st : &mut u32| {
|
||||
*st += 1;
|
||||
st.to_string()
|
||||
},
|
||||
" times."
|
||||
)),
|
||||
Tag::Div(
|
||||
"This has a red background!"
|
||||
).class("red"),
|
||||
Tag::Span("it's coming straight at us!").class("bigger"),
|
||||
Tag::Br,
|
||||
Tag::Span("leon's getting laaaaaaaaaaaaaaaaaaaaaarger").class("red bigger")
|
||||
)
|
||||
);
|
||||
let app = page.route();
|
||||
Server::new(([0, 0, 0, 0], 3000)).await.unwrap().serve(app, ()).await.unwrap();
|
||||
Server::new(([0, 0, 0, 0], 3000)).await.unwrap().serve(app, 0).await.unwrap();
|
||||
// weird rustc bug: if the second argument is omitted, rustc gets stuck in a recursion trying to figure out what type State is
|
||||
// *before* exiting on the error produced by the missing argument. this consumes cpu and slowly eats ram until it OOMs or you kill it.
|
||||
}
|
||||
Reference in New Issue
Block a user