diff --git a/web/add_provider.php b/web/add_provider.php index 739c088..84b0b03 100644 --- a/web/add_provider.php +++ b/web/add_provider.php @@ -4,10 +4,13 @@ // It uses the same Flask API as list_providers.php (http://172.25.1.105:5000). // When the form is submitted, it POSTs JSON to /providers. +// file settings +require_once __DIR__ . '/config.php'; + // Helper to call the API ------------------------------------------- function callApi(string $method, string $path, $body = null) { - $url = 'http://127.0.0.1:5000' . $path; + $url = BASE_API_URL . $path; $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); diff --git a/web/config.php b/web/config.php new file mode 100644 index 0000000..89b8151 --- /dev/null +++ b/web/config.php @@ -0,0 +1,6 @@ +// config.php + diff --git a/web/edit_provider.php b/web/edit_provider.php index b7ee0eb..a8e0d78 100644 --- a/web/edit_provider.php +++ b/web/edit_provider.php @@ -5,6 +5,9 @@ // This page allows editing a provider's details. // It expects a provider id passed via the query string: ?id=123 +// file settings +require_once __DIR__ . '/config.php'; + $provider_id = isset($_GET['id']) ? intval($_GET['id']) : 0; if ($provider_id <= 0) { echo '

Error

' . @@ -13,7 +16,7 @@ if ($provider_id <= 0) { } // API base URL -$api_base = 'http://127.0.0.1:5000'; +$url = BASE_API_URL . $path; // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST') { diff --git a/web/list_providers.php b/web/list_providers.php index 14c594d..811a8de 100644 --- a/web/list_providers.php +++ b/web/list_providers.php @@ -4,10 +4,13 @@ // It expects the Flask API to be reachable at http://127.0.0.1:5000 // The API endpoint for providers is /providers. +// file settings +require_once __DIR__ . '/config.php'; + // --- Helper to call the API ------------------------------------------- function callApi(string $method, string $path, $body = null) { - $url = 'http://127.0.0.1:5000' . $path; + $url = BASE_API_URL . $path; $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); diff --git a/web/settings.php b/web/settings.php index 70e6eac..7c63cf0 100644 --- a/web/settings.php +++ b/web/settings.php @@ -4,11 +4,14 @@ // It supports updating existing settings via PUT and creating a single new setting via POST. // The design follows the pattern used in list_providers.php. +// file settings +require_once __DIR__ . '/config.php'; + // --- Helper to call the Flask API ------------------------------------------- function callApi(string $method, string $path, $body = null) { // API base URL – update if your API is hosted elsewhere - $url = 'http://127.0.0.1:5000' . $path; + $url = BASE_API_URL . $path; $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);