|
|
@ -2,8 +2,7 @@ use std::fs::File;
|
|
|
|
use std::io::{BufReader, Read};
|
|
|
|
use std::io::{BufReader, Read};
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
|
|
|
|
use actix_web::http::header;
|
|
|
|
use actix_web::{get, HttpResponse};
|
|
|
|
use actix_web::{get, HttpRequest, HttpResponse};
|
|
|
|
|
|
|
|
use actix_web::web::{Data, Path};
|
|
|
|
use actix_web::web::{Data, Path};
|
|
|
|
|
|
|
|
|
|
|
|
use handlebars::Handlebars;
|
|
|
|
use handlebars::Handlebars;
|
|
|
@ -13,13 +12,11 @@ use serde_json::json;
|
|
|
|
use crate::Result;
|
|
|
|
use crate::Result;
|
|
|
|
|
|
|
|
|
|
|
|
#[get("/+{id}")]
|
|
|
|
#[get("/+{id}")]
|
|
|
|
pub async fn get(req: HttpRequest, id: Path<String>, hb: Data<Handlebars<'_>>) -> Result<HttpResponse> {
|
|
|
|
pub async fn get(id: Path<String>, hb: Data<Handlebars<'_>>) -> Result<HttpResponse> {
|
|
|
|
println!("HIHIHI");
|
|
|
|
|
|
|
|
let mut path = PathBuf::from("replays");
|
|
|
|
let mut path = PathBuf::from("replays");
|
|
|
|
let id: String = id.into_inner();
|
|
|
|
let id: String = id.into_inner();
|
|
|
|
path.push(&id);
|
|
|
|
path.push(&id);
|
|
|
|
let file: File = File::open(&path)?;
|
|
|
|
let file: File = File::open(&path)?;
|
|
|
|
info!("loaded file: {:?}", path);
|
|
|
|
|
|
|
|
let mut buffer = BufReader::new(file);
|
|
|
|
let mut buffer = BufReader::new(file);
|
|
|
|
let mut file_contents = String::new();
|
|
|
|
let mut file_contents = String::new();
|
|
|
|
buffer.read_to_string(&mut file_contents)?;
|
|
|
|
buffer.read_to_string(&mut file_contents)?;
|
|
|
|