1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use console::Emoji;
use std::net::SocketAddr;
use std::path::PathBuf;
use warp::Filter;
static SERVING: Emoji<'_, '_> = Emoji("🛰️ ", "");
pub async fn serve_exported(dir: PathBuf, host: String, port: u16) {
let dir = dir.join(".perseus/dist/exported");
let files = warp::any().and(warp::fs::dir(dir));
let host = if host == "localhost" {
"127.0.0.1".to_string()
} else {
host
};
let addr: SocketAddr = format!("{}:{}", host, port).parse().unwrap();
println!(
" [3/3] {} Your exported app is now live at <http://{host}:{port}>!",
SERVING,
host = host,
port = port
);
warp::serve(files).run(addr).await
}