Setup project.
This commit is contained in:
parent
1c377264b7
commit
b9fe3b0c15
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/target
|
||||||
|
*.swp
|
1698
Cargo.lock
generated
Normal file
1698
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
14
Cargo.toml
Normal file
14
Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[package]
|
||||||
|
name = "morethantext_web"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
# morethantext = { git=https://gitea.baskinprattle.com/jbaskin/MoreThanText.git }
|
||||||
|
async-std = { version = "1.10.0", features = ["attributes"] }
|
||||||
|
tide = "0.16.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tide-testing = "0.1.3"
|
40
src/main.rs
Normal file
40
src/main.rs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
use tide::{Request, Response};
|
||||||
|
|
||||||
|
#[async_std::main]
|
||||||
|
async fn main() -> tide::Result<()> {
|
||||||
|
let app = app_setup().await;
|
||||||
|
app.listen("127.0.0.1:8080").await?;
|
||||||
|
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 {
|
||||||
|
let mut res = Response::new(200);
|
||||||
|
res.set_body("<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<h1>Welcome to BaskinPrattle.</h1>
|
||||||
|
<p>The code for the site is <a href=\"https://gitea.baskinprattle.com/jbaskin/mtt-server\">here</a>.</p>
|
||||||
|
</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();
|
||||||
|
assert_eq!(response.status(), tide::http::StatusCode::Ok);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user