Added the ability to change addresses.
This commit is contained in:
parent
6b68a0d186
commit
ec3f033ff6
@ -2,18 +2,23 @@ use axum::{response::Html, routing::get, Router};
|
||||
use clap::Parser;
|
||||
use dioxus::prelude::*;
|
||||
|
||||
const LOCALHOST: &str = "127.0.0.1";
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct Args {
|
||||
/// Post used
|
||||
#[arg(short, long, default_value_t = 3000)]
|
||||
port: u16
|
||||
port: u16,
|
||||
/// IP used
|
||||
#[arg(short, long, default_value_t = LOCALHOST.to_string())]
|
||||
address: String,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let args = Args::parse();
|
||||
let url = format!("127.0.0.1:{}", args.port);
|
||||
let url = format!("{}:{}", args.address, args.port);
|
||||
let app = Router::new().route("/", get(|| app_endpoint()));
|
||||
let listener = tokio::net::TcpListener::bind(&url).await.unwrap();
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
|
@ -4,6 +4,7 @@ import aiohttp
|
||||
|
||||
from asyncio import create_subprocess_exec
|
||||
from pathlib import Path
|
||||
from socket import gethostbyname, gethostname
|
||||
from unittest import IsolatedAsyncioTestCase
|
||||
|
||||
|
||||
@ -55,3 +56,11 @@ class SingleBootTC(IsolatedAsyncioTestCase):
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(f"http://localhost:{port}") as response:
|
||||
self.assertEqual(response.status, 200)
|
||||
|
||||
async def test_alt_address_boot(self):
|
||||
"""Can it boot off an alternate address?"""
|
||||
addr = gethostbyname(gethostname())
|
||||
await self.servers.create_server("-a", addr)
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(f"http://{addr}:3000") as response:
|
||||
self.assertEqual(response.status, 200)
|
||||
|
Loading…
Reference in New Issue
Block a user