Display list of links

This commit is contained in:
SinTan1729
2023-04-03 11:55:27 -05:00
parent b9d76b6734
commit a1f73c8a9d
6 changed files with 36 additions and 7 deletions

View File

@@ -2,7 +2,7 @@ use actix_files::{Files, NamedFile};
use actix_web::{
get,
web::{self, Redirect},
App, HttpServer, Responder,
App, HttpResponse, HttpServer, Responder,
};
mod database;
mod utils;
@@ -13,6 +13,11 @@ mod utils;
// Return all active links
#[get("/api/all")]
async fn getall() -> HttpResponse {
HttpResponse::Ok().body(utils::getall())
}
// 404 error page
#[get("/err/404")]
async fn error404() -> impl Responder {
@@ -36,6 +41,7 @@ async fn main() -> std::io::Result<()> {
App::new()
.service(link_handler)
.service(error404)
.service(getall)
.service(Files::new("/", "./resources/").index_file("index.html"))
})
.bind(("0.0.0.0", 2000))?