share/src/main.rs

34 lines
724 B
Rust
Raw Normal View History

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
use crate::vistas::{
root::basic,
upload::upload,
};
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-20 23:20:04 +02:00
.route("/u", post(upload));
// 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();
}