-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5dec915
commit af63fbe
Showing
2 changed files
with
31 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,37 @@ | ||
mod meow; | ||
mod api; | ||
mod meow; | ||
|
||
use crate::api::api::*; | ||
use warp::Filter; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
// Define a filter that matches a GET request to the /jsonl endpoint. | ||
let jsonl_route = warp::path!("jsonl") | ||
.and(warp::get()) | ||
.map(|| { | ||
// Read the JSONL file and return it as a response. | ||
let file_content = read_jsonl_file(); | ||
warp::reply::with_header(file_content, warp::http::header::CONTENT_TYPE, "application/json") | ||
}); | ||
// Replace "your_jsonl_file.jsonl" with the path to your JSONL file. | ||
let config = read_meow("/var/maid/maid_lists/embedded/config.meow", false); | ||
let file_path = format!("{}{}", config["REPORT_BASE_PATH"], config["REPORT_LOG"]); | ||
|
||
let jsonl_route = warp::path!("jsonl").and(warp::get()).map(|| { | ||
// Read the JSONL file and return it as a response. | ||
let file_content = read_file(file_path); | ||
warp::reply::with_header( | ||
file_content, | ||
warp::http::header::CONTENT_TYPE, | ||
"application/json", | ||
) | ||
}); | ||
|
||
|
||
let index_page = config["INDEX"].to_string(); | ||
let index = warp::path!("/").and(warp::get()).map(|| { | ||
let file_content = read_file(index_page); | ||
warp::reply::with_header( | ||
file_content, | ||
warp::http::header::CONTENT_TYPE, | ||
"text/html", | ||
) | ||
}); | ||
|
||
// Start the Warp server. | ||
warp::serve(jsonl_route) | ||
.run(([127, 0, 0, 1], 3030)) | ||
.await; | ||
} | ||
warp::serve(jsonl_route, index).run(([127, 0, 0, 1], 8000)).await; | ||
} |