diff options
Diffstat (limited to 'indexer')
-rw-r--r-- | indexer/Cargo.toml | 1 | ||||
-rw-r--r-- | indexer/src/main.rs | 15 |
2 files changed, 13 insertions, 3 deletions
diff --git a/indexer/Cargo.toml b/indexer/Cargo.toml index 5aa5184..7b64bb3 100644 --- a/indexer/Cargo.toml +++ b/indexer/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dependencies] actix-web = "4.2.1" +actix-web-lab = "0.18.5" actix-cors = "0.6.3" scraper = "0.12.0" html2text = "0.4.3" diff --git a/indexer/src/main.rs b/indexer/src/main.rs index 952af96..7d5a1af 100644 --- a/indexer/src/main.rs +++ b/indexer/src/main.rs @@ -32,7 +32,7 @@ struct AppState { async fn main() -> std::io::Result<()> { println!("Hello, world! Im the indexer!"); - serve_http_endpoint("0.0.0.0", 4444).await + serve_http_endpoint("0.0.0.0", 8080).await } async fn serve_http_endpoint(address: &str, port: u16) -> std::io::Result<()> { @@ -45,7 +45,16 @@ async fn serve_http_endpoint(address: &str, port: u16) -> std::io::Result<()> { .wrap(cors) .app_data(shared_state.clone()) .service(add_resource) - .service(web::resource(["/search", "/search/", "/search/{query}"]).to(search)) + .service( + web::resource(["/api/search", "/api/search/", "/api/search/{query}"]).to(search), + ) + .service( + actix_web_lab::web::spa() + .index_file("./frontend/dist/index.html") + .static_resources_mount("/") + .static_resources_location("./frontend/dist") + .finish(), + ) //TODO: maybe separate gui backend from api? }) .bind((address, port))? .run() @@ -53,7 +62,7 @@ async fn serve_http_endpoint(address: &str, port: u16) -> std::io::Result<()> { } //TODO: sufficiently simmilar word in search (algorithm) -#[post("/resource")] +#[post("/api/resource")] async fn add_resource( data: web::Data<AppState>, resource: web::Json<CrawledResource>, |