【发布时间】:2020-07-20 20:37:23
【问题描述】:
我有一个使用 Warp 提供静态文件的简单 Web 服务器。我按照 Warp 文档中的示例获得以下信息:
let index_html = warp::path("index.html").map(handlers::index_html); // reply is handled in `handlers::`
let script_js = warp::path("script.js").map(handlers::script_js);
let routes = warp::get().and(index_html.or(script_js));
warp::serve(routes).run(([127, 0, 0, 1], 8000)).await;
这会在localhost:8000/index.html 和localhost:8000/script.js 请求时返回文件。
我想从localhost:8000 而不是/index.html 提供索引文件,但我不确定如何使用warp::path 指定域根目录。我试过用
warp::path("index.html")
warp::path()warp::path("")warp::path("/")
但没有成功。
【问题讨论】: