dev #60
+7
-15
@@ -1334,27 +1334,19 @@ def register_web_routes(app, dependencies):
|
||||
import os
|
||||
import socket
|
||||
|
||||
# Get request body
|
||||
try:
|
||||
body = await request.json()
|
||||
except:
|
||||
body = {}
|
||||
|
||||
# Get core container URL
|
||||
core_host = os.environ.get("CORE_API_HOST", "nfoguard-core")
|
||||
core_port = os.environ.get("CORE_API_PORT", "8080")
|
||||
|
||||
# Forward query parameters from the request
|
||||
query_string = str(request.url.query) if request.url.query else ""
|
||||
core_url = f"http://{core_host}:{core_port}/manual/scan"
|
||||
if query_string:
|
||||
core_url += f"?{query_string}"
|
||||
|
||||
try:
|
||||
# Prepare request data
|
||||
data = json.dumps(body).encode('utf-8')
|
||||
|
||||
# Create request with timeout
|
||||
req = urllib.request.Request(
|
||||
core_url,
|
||||
data=data,
|
||||
headers={'Content-Type': 'application/json'}
|
||||
)
|
||||
# Create request with timeout (no body needed for query parameters)
|
||||
req = urllib.request.Request(core_url, method='POST')
|
||||
|
||||
# Make request with timeout
|
||||
with urllib.request.urlopen(req, timeout=30) as response:
|
||||
|
||||
Reference in New Issue
Block a user