php config file

This commit is contained in:
matt committed 2026-10-17 05:55:48 -07:00
1 parent 48e2e7061e
commit a08a4c0314
5 files changed
+22 -4

No files matched your search

+4 -1
View File
@@ -4,10 +4,13 @@
// It uses the same Flask API as list_providers.php (http://172.25.1.105:5000). // 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. // When the form is submitted, it POSTs JSON to /providers.
// file settings
require_once __DIR__ . '/config.php';
// Helper to call the API ------------------------------------------- // Helper to call the API -------------------------------------------
function callApi(string $method, string $path, $body = null) 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); $ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+6
View File
@@ -0,0 +1,6 @@
// config.php
<?php
// Base URL for the API
define('BASE_API_URL', 'http://127.0.0.1:5000');
?>
+4 -1
View File
@@ -5,6 +5,9 @@
// This page allows editing a provider's details. // This page allows editing a provider's details.
// It expects a provider id passed via the query string: ?id=123 // 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; $provider_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($provider_id <= 0) { if ($provider_id <= 0) {
echo '<h1>Error</h1>' . echo '<h1>Error</h1>' .
@@ -13,7 +16,7 @@ if ($provider_id <= 0) {
} }
// API base URL // API base URL
$api_base = 'http://127.0.0.1:5000'; $url = BASE_API_URL . $path;
// Handle form submission // Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+4 -1
View File
@@ -4,10 +4,13 @@
// It expects the Flask API to be reachable at http://127.0.0.1:5000 // It expects the Flask API to be reachable at http://127.0.0.1:5000
// The API endpoint for providers is /providers. // The API endpoint for providers is /providers.
// file settings
require_once __DIR__ . '/config.php';
// --- Helper to call the API ------------------------------------------- // --- Helper to call the API -------------------------------------------
function callApi(string $method, string $path, $body = null) 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); $ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+4 -1
View File
@@ -4,11 +4,14 @@
// It supports updating existing settings via PUT and creating a single new setting via POST. // 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. // The design follows the pattern used in list_providers.php.
// file settings
require_once __DIR__ . '/config.php';
// --- Helper to call the Flask API ------------------------------------------- // --- Helper to call the Flask API -------------------------------------------
function callApi(string $method, string $path, $body = null) function callApi(string $method, string $path, $body = null)
{ {
// API base URL – update if your API is hosted elsewhere // 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); $ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);