Skip to content

Commit

Permalink
Add routing
Browse files Browse the repository at this point in the history
Signed-off-by: Aisuko <[email protected]>
  • Loading branch information
Aisuko committed Jul 30, 2024
1 parent 6d3fa0d commit cd4bd2a
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 11 deletions.
45 changes: 45 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'lupinIII'",
"cargo": {
"args": [
"build",
"--bin=lupinIII",
"--package=lupinIII"
],
"filter": {
"name": "lupinIII",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'lupinIII'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=lupinIII",
"--package=lupinIII"
],
"filter": {
"name": "lupinIII",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# lupin
inference engine on GPUs

Inference API aggregator for performance requirements.
32 changes: 22 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
use axum::{response::Html, routing::get, Router};
// coding=utf-8

// Copyright [2024] [SkywardAI]
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

pub mod routing;

use routing::routers::create_router;


#[tokio::main]
async fn main() {
// single router
let app = Router::new().route("/", get(handler));

let listener = tokio::net::TcpListener::bind("127.0.0.1:8000")
.await
.unwrap();
let app = create_router();

let listener = tokio::net::TcpListener::bind("0.0.0.0:8000").await.unwrap();

println!("Listening on: {}", listener.local_addr().unwrap());

axum::serve(listener, app).await.unwrap();
}

async fn handler() -> Html<&'static str> {
Html("<h1>Hello, World!</h1>")
}
1 change: 1 addition & 0 deletions src/routing/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod routers;
19 changes: 19 additions & 0 deletions src/routing/routers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// routers.rs
use axum::{response::Html, routing::get, Router};

pub fn create_router() -> Router {
let inference = Router::new()
.route("/", get(inference));

Router::new()
.route("/", get(handler))
.nest("/inference", inference)
}

async fn handler() -> Html<&'static str> {
Html("<h1>Welcome!</h1>")
}

async fn inference() -> Html<&'static str> {
Html("<h1>Inference!</h1>")
}

0 comments on commit cd4bd2a

Please sign in to comment.