Commit fc97e8fb authored by Chunchi Che's avatar Chunchi Che

succeed in interacting with neos-ts

parent 2961075e
use std::{net::SocketAddr, str::FromStr}; use std::{net::SocketAddr, str::FromStr};
use warp::Filter; use warp::Filter;
const ADDR: &str = "127.0.0.1:3000"; const ADDR: &str = "127.0.0.1:3030";
#[tokio::main] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> anyhow::Result<()> {
pretty_env_logger::try_init()?; pretty_env_logger::try_init()?;
let hello = warp::path!("hello" / String).map(|name| format!("hello, {}", name)); // todo: use CORS correctly
let cors = warp::cors()
.allow_any_origin()
.allow_credentials(true)
.allow_header("content-type")
.allow_method("GET");
let hello = warp::path!("hello" / String)
.map(|name| format!("hello, {}", name))
.with(cors);
warp::serve(hello).run(SocketAddr::from_str(ADDR)?).await; warp::serve(hello).run(SocketAddr::from_str(ADDR)?).await;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment