HOLY SHITT WE HAVE A SEARCH ENGINE
This commit is contained in:
@@ -39,13 +39,17 @@ fn create_lua_function_table(lua: &Lua) -> mlua::Result<Table> {
|
||||
let snippet: String = values.get("snippet").unwrap();
|
||||
let url: String = values.get("url").unwrap();
|
||||
|
||||
let url = url.trim_matches('"').trim_matches('\\');
|
||||
|
||||
dbg!(&url);
|
||||
|
||||
let html = html! {
|
||||
div {
|
||||
A.href(#url) {
|
||||
#title
|
||||
A.href(url) {
|
||||
#title.to_string()
|
||||
}
|
||||
P {
|
||||
#snippet
|
||||
#snippet.to_string()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,6 +21,8 @@ pub async fn main_server(config_location: Option<String>) {
|
||||
.route("/", get(handler))
|
||||
.with_state(config_location);
|
||||
|
||||
println!("Running webserver");
|
||||
|
||||
// run our app with hyper, listening globally on port 3000
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
@@ -43,7 +45,13 @@ async fn handler(
|
||||
|
||||
let html = results
|
||||
.iter()
|
||||
.map(|result| format!("<li>{:#?}</li>", result))
|
||||
.flat_map(|result| result.iter())
|
||||
.map(|(_, value)| {
|
||||
let tostring: mlua::Function = lua_instance.globals().get("tostring").unwrap();
|
||||
let value: String = tostring.call(value.clone()).unwrap();
|
||||
|
||||
format!("<li>{}</li>", value)
|
||||
})
|
||||
.collect::<Vec<String>>()
|
||||
.join("");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user