Compare commits

...

2 commits

Author SHA1 Message Date
2b6deadf6c readme: yoper 2024-10-23 23:03:18 -03:00
6c19fd55e6 mejorar index 2024-10-16 20:52:48 -03:00
2 changed files with 12 additions and 3 deletions

View file

@ -13,6 +13,7 @@ scrapeo "masivo" de precios y datos en supermercados argentinos
- [SEPAME](https://sepame.net/): muestra todos los precios de todas las sucursales según el [dataset SEPA](https://datos.produccion.gob.ar/dataset/sepa-precios) - [SEPAME](https://sepame.net/): muestra todos los precios de todas las sucursales según el [dataset SEPA](https://datos.produccion.gob.ar/dataset/sepa-precios)
- [Coto_bot](https://twitter.com/BotCoto) (repo: [Vosinepi/webScrapping_ETL_canasta_basica](https://github.com/Vosinepi/webScrapping_ETL_canasta_basica)) - [Coto_bot](https://twitter.com/BotCoto) (repo: [Vosinepi/webScrapping_ETL_canasta_basica](https://github.com/Vosinepi/webScrapping_ETL_canasta_basica))
- [@canastita_bot](https://twitter.com/canastita_bot) y [@asadito_bot](https://twitter.com/asadito_bot) de [Charly Maslaton](https://twitter.com/charlymasla) - [@canastita_bot](https://twitter.com/canastita_bot) y [@asadito_bot](https://twitter.com/asadito_bot) de [Charly Maslaton](https://twitter.com/charlymasla)
- [Yoper](https://www.yoper.com.ar/) ([@YoperLATAM](https://x.com/YoperLATAM))
## componentes ## componentes

View file

@ -1,6 +1,6 @@
use axum::{ use axum::{
extract::{Path, State}, extract::{Path, State},
http::StatusCode, http::{Response, StatusCode},
response::IntoResponse, response::IntoResponse,
routing::get, routing::get,
Json, Router, Json, Router,
@ -17,8 +17,15 @@ use sqlx::{
}; };
use std::{env, str::FromStr, time::Duration}; use std::{env, str::FromStr, time::Duration};
async fn index() -> &'static str { async fn index() -> impl IntoResponse {
"Hello, world! <a href=https://github.com/catdevnull/preciazo>catdevnull/preciazo</a>" Response::builder()
.header("Content-Type", "text/html")
.body("<style>html,body{font-family:sans-serif;}</style>
<h1>old preciazo API</h1>
Hello, world! <a href=https://github.com/catdevnull/preciazo>catdevnull/preciazo</a><br>
<a href=mailto:hola@nulo.in>hola@nulo.in</a>
".to_string())
.unwrap()
} }
async fn healthcheck(State(pool): State<SqlitePool>) -> impl IntoResponse { async fn healthcheck(State(pool): State<SqlitePool>) -> impl IntoResponse {
let one_day_ago = chrono::Utc::now() - chrono::Duration::hours(25); let one_day_ago = chrono::Utc::now() - chrono::Duration::hours(25);
@ -308,6 +315,7 @@ async fn main() {
let app = Router::new() let app = Router::new()
.route("/", get(index)) .route("/", get(index))
.route("/api/", get(index))
.route("/api/healthcheck", get(healthcheck)) .route("/api/healthcheck", get(healthcheck))
.route("/api/0/best-selling-products", get(get_best_selling)) .route("/api/0/best-selling-products", get(get_best_selling))
.route("/api/0/ean/:ean/history", get(get_product_history)) .route("/api/0/ean/:ean/history", get(get_product_history))