v.0.11.3 api-server public port 8000

This commit is contained in:
tiijay
2025-11-21 19:07:41 +00:00
parent c27b97fc71
commit 115e402b0d
5 changed files with 27 additions and 19 deletions

View File

@@ -7,8 +7,9 @@
"dockerfile": "Dockerfile"
},
"runArgs": [
"--network=dev-network",
"--name=api-server"
// "--network=dev-network",
"--name=api-server",
"-p", "8000:8000"
],
// "image": "mcr.microsoft.com/devcontainers/python:1-3.12",
// "image": "python:latest",
@@ -31,11 +32,11 @@
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [9000],
"forwardPorts": [8000],
// Use 'portsAttributes' to set default properties for specific forwarded ports.
// More info: https://containers.dev/implementors/json_reference/#port-attributes
"portsAttributes": {
"9000": {
"8000": {
"label": "API-Server Application",
"onAutoForward": "notify"
}

View File

@@ -7,13 +7,13 @@ from app.models import Item, dummy_items
app = FastAPI(title="FastAPI Server", version="1.0.0")
# CORS middleware to allow client requests
# app.add_middleware(
# CORSMiddleware,
# # allow_origins=["http://localhost:3000", "http://client:3000"],
# allow_credentials=True,
# allow_methods=["*"],
# allow_headers=["*"],
# )
app.add_middleware(
CORSMiddleware,
# allow_origins=["http://localhost:3000", "http://client:3000"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")

View File

@@ -7,8 +7,9 @@
"dockerfile": "Dockerfile"
},
"runArgs": [
"--network=dev-network",
"--name=pico-client"
// "--network=dev-network",
"--name=pico-client",
"--add-host", "j-agent-01:192.168.178.105"
],
// "image": "mcr.microsoft.com/devcontainers/python:1-3.12",
// "image": "python:latest",

View File

@@ -54,10 +54,10 @@ async def main(
) -> None:
# Run both tasks concurrently
await asyncio.gather(
sync_ntp_time_task(),
weather_check_task(weather_checker),
# sync_ntp_time_task(),
# weather_check_task(weather_checker),
api_server_check_task(api_server_checker),
print_time_task(),
# print_time_task(),
)

View File

@@ -1,7 +1,9 @@
import urequests # type: ignore
import json
BASE_API_URL: str = "http://api-server:8000"
# BASE_API_URL: str = "http://api-server:8000"
# BASE_API_URL: str = "http://j-agent-01:8000"
BASE_API_URL: str = "http://192.168.178.105:8000"
class API_Server_Checker:
@@ -16,6 +18,7 @@ class API_Server_Checker:
)
print(f"query: {items_url}")
r: any
try:
r = urequests.get(items_url)
print("Status-Code:", r.status_code)
@@ -26,9 +29,12 @@ class API_Server_Checker:
else:
print("api-server error:", json_resp["error"]["message"])
except OSError as e:
print(f"api-server call failed: {e}")
print("Network error:", e)
except Exception as e:
print("Error:", e)
finally:
r.close()
if r:
r.close()
def check(self, item_id: int):
self._get_items(item_id)