2022-10-21 12:12:53 +02:00
|
|
|
pub mod lib;
|
2022-10-21 11:07:34 +02:00
|
|
|
pub mod vistas;
|
|
|
|
|
2022-10-20 23:20:04 +02:00
|
|
|
use axum::{
|
|
|
|
routing::{get, post},
|
|
|
|
Router,
|
|
|
|
};
|
|
|
|
use std::net::SocketAddr;
|
2022-10-21 11:07:34 +02:00
|
|
|
|
2022-10-21 13:36:53 +02:00
|
|
|
use crate::vistas::{root::basic, upload::upload, download::get_file};
|
2022-10-20 23:20:04 +02:00
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() {
|
|
|
|
// initialize tracing
|
|
|
|
tracing_subscriber::fmt::init();
|
|
|
|
|
|
|
|
// build our application with a route
|
|
|
|
let app = Router::new()
|
|
|
|
// `GET /` goes to `root`
|
2022-10-21 11:07:34 +02:00
|
|
|
.route("/", get(basic))
|
2022-10-21 13:36:53 +02:00
|
|
|
.route("/u", post(upload))
|
|
|
|
.route("/f/:hash", get(get_file));
|
2022-10-20 23:20:04 +02:00
|
|
|
|
|
|
|
// run our app with hyper
|
|
|
|
// `axum::Server` is a re-export of `hyper::Server`
|
|
|
|
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
|
|
|
|
tracing::debug!("listening on {}", addr);
|
|
|
|
axum::Server::bind(&addr)
|
|
|
|
.serve(app.into_make_service())
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
}
|