assets/assets.rs
1use std::time::Duration;
2
3use flyer::{server, view::ViewData};
4
5/*
6
7TODO: Create file called `style.css` in folder called `assets` and copy the content below in the file.
8
9```css
10.body {
11 background-color: block;
12}
13
14h1 {
15 color: white;
16}
17```
18
19TODO: Create file called `index.html` in folder called `views` and copy the content below in the file.
20
21```html
22<!DOCTYPE html>
23<html lang="en">
24<head>
25 <meta charset="UTF-8">
26 <meta name="viewport" content="width=device-width, initial-scale=1.0">
27 <base href="http://127.0.0.1:9999/">
28 <title>Assets Test</title>
29 <link href="{{ url(path="style.css") }}" rel="stylesheet">
30</head>
31<body>
32 <h1>Hello World</h1>
33</body>
34</html>
35```
36
37*/
38
39fn main() {
40 let server = server("127.0.0.1", 9999)
41 .assets("assets", 1024, Duration::from_secs((60 * 60) * 2).as_millis())
42 .view("views");
43
44 server.router().get("/", async |_req, res| {
45 return res.view("index.html", Some(ViewData::new()));
46 });
47
48 println!("Running Server: {}", server.address());
49
50 server.listen();
51}