Remove port parameter

This commit is contained in:
Eden Kirin
2023-04-21 17:56:35 +02:00
parent fd71fa276c
commit 270f742c95
4 changed files with 10 additions and 14 deletions

View File

@ -1,12 +1,11 @@
const sdk = require("./fh_sdk"); const sdk = require("./fh_sdk");
const FAIRHOPPER_HOST = "http://127.0.0.1"; const FAIRHOPPER_HOST = "https://api.fairhopper.mjerenja.com";
const FAIRHOPPER_PORT = 8010;
async function main() { async function main() {
const fh = new sdk.FairHopper(FAIRHOPPER_HOST, FAIRHOPPER_PORT); const fh = new sdk.FairHopper(FAIRHOPPER_HOST);
console.log(`Pinging FairHopper server on ${FAIRHOPPER_HOST}:${FAIRHOPPER_PORT}`); console.log(`Pinging FairHopper server on ${FAIRHOPPER_HOST}`);
const pingResult = await fh.ping(); const pingResult = await fh.ping();
console.log("Ping result:", pingResult); console.log("Ping result:", pingResult);
console.log(); console.log();

View File

@ -36,9 +36,8 @@ const Direction = {
}; };
class FairHopper { class FairHopper {
constructor(host, port) { constructor(host) {
this.host = host; this.host = host;
this.port = port;
this.defaultHeaders = { this.defaultHeaders = {
Accept: "application/json", Accept: "application/json",
@ -47,7 +46,7 @@ class FairHopper {
} }
formatUrl(path) { formatUrl(path) {
return `${this.host}:${this.port}${path}`; return `${this.host}${path}`;
} }
async ping() { async ping() {

View File

@ -1,13 +1,12 @@
from fh_sdk import Direction, FairHopper, PositionError from fh_sdk import Direction, FairHopper, PositionError
FAIRHOPPER_HOST = "http://127.0.0.1" FAIRHOPPER_HOST = "https://api.fairhopper.mjerenja.com"
FAIRHOPPER_PORT = 8010
def main() -> None: def main() -> None:
fh = FairHopper(FAIRHOPPER_HOST, FAIRHOPPER_PORT) fh = FairHopper(FAIRHOPPER_HOST)
print(f"Pinging FairHopper server on {FAIRHOPPER_HOST}:{FAIRHOPPER_PORT}") print(f"Pinging FairHopper server on {FAIRHOPPER_HOST}")
res = fh.ping() res = fh.ping()
print("Ping result:", res) print("Ping result:", res)
print() print()

View File

@ -70,12 +70,11 @@ class GameInfoResponse(BaseModel):
class FairHopper: class FairHopper:
def __init__(self, host, port) -> None: def __init__(self, host: str) -> None:
self.host = host self.host = host
self.port = port
def format_url(self, path: str) -> str: def format_url(self, path: str) -> str:
return f"{self.host}:{self.port}{path}" return f"{self.host}{path}"
def ping(self) -> PingResponse: def ping(self) -> PingResponse:
r = requests.get(self.format_url("/ping")) r = requests.get(self.format_url("/ping"))