share/src/main.rs

33 lines
788 B
Rust

pub mod lib;
pub mod vistas;
use axum::{
routing::{get, post},
Router,
};
use std::net::SocketAddr;
use crate::vistas::{root::basic, upload::upload, download::get_file};
#[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`
.route("/", get(basic))
.route("/u", post(upload))
.route("/f/:hash", get(get_file));
// 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();
}