2022-06-02 13:14:14 -04:00
|
|
|
use tide::{http::StatusCode, Request, Response};
|
2022-02-26 11:18:08 -05:00
|
|
|
|
|
|
|
#[async_std::main]
|
|
|
|
async fn main() -> tide::Result<()> {
|
|
|
|
let app = app_setup().await;
|
2022-06-03 11:52:18 -04:00
|
|
|
app.listen("127.0.0.1:9090").await?;
|
2022-02-26 11:18:08 -05:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn app_setup() -> tide::Server<()> {
|
|
|
|
let mut app = tide::new();
|
|
|
|
app.at("/").get(home);
|
|
|
|
return app;
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn home(_req: Request<()>) -> tide::Result {
|
2022-06-02 13:14:14 -04:00
|
|
|
let mut res = Response::new(StatusCode::Ok);
|
2022-02-26 11:18:08 -05:00
|
|
|
res.set_body("<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<body>
|
|
|
|
<h1>Welcome to BaskinPrattle.</h1>
|
2022-03-21 14:15:51 -04:00
|
|
|
<p>The code for the site is <a href=\"https://gitea.baskinprattle.com/jbaskin/morethantext-web\">here</a>.</p>
|
|
|
|
<p>And the latest x86_64 Linux build is <a href=\"https://jenkins.baskinprattle.com/job/morethantext-web/\">here</a>.</p>
|
2022-02-26 11:18:08 -05:00
|
|
|
</body>
|
|
|
|
</html>");
|
|
|
|
res.append_header("Content-Type", "text/html; charset=UTF-8");
|
|
|
|
Ok(res)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod basic_tests {
|
|
|
|
use super::*;
|
|
|
|
use tide_testing::TideTestingExt;
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
async fn home_page_available() {
|
|
|
|
let app = app_setup().await;
|
|
|
|
let response = app.get("/").await.unwrap();
|
2022-06-02 13:14:14 -04:00
|
|
|
assert_eq!(response.status(), StatusCode::Ok);
|
2022-02-26 11:18:08 -05:00
|
|
|
}
|
|
|
|
}
|