add generation
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use rocket::fs::NamedFile;
|
||||
use rocket::http::Method;
|
||||
use rocket::http::Status;
|
||||
use rocket::response::{Responder, status};
|
||||
use rocket::serde::{Deserialize, json::Json};
|
||||
use rocket::{self, get, launch, post, routes};
|
||||
use rocket::http::Method;
|
||||
use rocket_cors::{AllowedOrigins, CorsOptions};
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
@@ -206,18 +206,20 @@ async fn generate(request: Json<GenerationRequest<'_>>) -> Result<NamedFile, Gen
|
||||
|
||||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
let cors = CorsOptions::default()
|
||||
.allowed_origins(AllowedOrigins::all())
|
||||
.allowed_methods(
|
||||
vec![Method::Get, Method::Post]
|
||||
.into_iter()
|
||||
.map(From::from)
|
||||
.collect(),
|
||||
)
|
||||
.allow_credentials(true);
|
||||
let cors = CorsOptions::default()
|
||||
.allowed_origins(AllowedOrigins::all())
|
||||
.allowed_methods(
|
||||
vec![Method::Get, Method::Post]
|
||||
.into_iter()
|
||||
.map(From::from)
|
||||
.collect(),
|
||||
)
|
||||
.allow_credentials(true);
|
||||
|
||||
rocket::build().mount(
|
||||
"/api/v1",
|
||||
routes![index, list_directories, list_directory, get_file, generate],
|
||||
).attach(cors.to_cors().unwrap())
|
||||
rocket::build()
|
||||
.mount(
|
||||
"/api/v1",
|
||||
routes![index, list_directories, list_directory, get_file, generate],
|
||||
)
|
||||
.attach(cors.to_cors().unwrap())
|
||||
}
|
||||
|
Reference in New Issue
Block a user