-
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
af63fbe
commit e134868
Showing
3 changed files
with
3 additions
and
62 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,18 +0,0 @@ | ||
use crate::meow::meow::*; | ||
use std::fs::File; | ||
|
||
pub fn read_file(path: String) -> String { | ||
|
||
match File::open(file_path) { | ||
Ok(file) => { | ||
use std::io::Read; | ||
let mut reader = std::io::BufReader::new(file); | ||
let mut content = String::new(); | ||
reader | ||
.read_to_string(&mut content) | ||
.expect("Failed to read file"); | ||
content | ||
} | ||
Err(_) => String::from("Error reading the JSONL file"), | ||
} | ||
} | ||
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,37 +1,3 @@ | ||
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. | ||
// 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, index).run(([127, 0, 0, 1], 8000)).await; | ||
} | ||
fn main() { | ||
println!("A"); | ||
} |