2019-06-19 06:20:50 +02:00
|
|
|
pub mod configuration;
|
|
|
|
pub mod configuration_two;
|
|
|
|
pub mod directory;
|
2019-06-26 10:27:25 +02:00
|
|
|
|
2019-06-17 23:35:47 +02:00
|
|
|
// <individual-file>
|
|
|
|
use actix_files::NamedFile;
|
2019-06-28 19:31:30 +02:00
|
|
|
use actix_web::{HttpRequest, Result};
|
2019-06-17 23:35:47 +02:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2019-12-28 19:36:24 +01:00
|
|
|
async fn index(req: HttpRequest) -> Result<NamedFile> {
|
2019-06-26 10:27:25 +02:00
|
|
|
let path: PathBuf = req.match_info().query("filename").parse().unwrap();
|
2019-06-17 23:35:47 +02:00
|
|
|
Ok(NamedFile::open(path)?)
|
|
|
|
}
|
|
|
|
|
2020-09-12 17:21:54 +02:00
|
|
|
#[actix_web::main]
|
2019-12-28 19:36:24 +01:00
|
|
|
async fn main() -> std::io::Result<()> {
|
2019-06-28 19:31:30 +02:00
|
|
|
use actix_web::{web, App, HttpServer};
|
|
|
|
|
2019-06-26 10:27:25 +02:00
|
|
|
HttpServer::new(|| App::new().route("/{filename:.*}", web::get().to(index)))
|
2020-09-12 17:21:54 +02:00
|
|
|
.bind("127.0.0.1:8080")?
|
2019-06-26 10:27:25 +02:00
|
|
|
.run()
|
2019-12-28 19:36:24 +01:00
|
|
|
.await
|
2019-06-17 23:35:47 +02:00
|
|
|
}
|
|
|
|
// </individual-file>
|