Spaces:
Running
Running
| ```php | |
| // Database configuration | |
| define('DB_HOST', 'localhost'); | |
| define('DB_USER', 'root'); | |
| define('DB_PASS', ''); | |
| define('DB_NAME', 'cebelarstvo_cigoj'); | |
| // Establish database connection | |
| try { | |
| $pdo = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME, DB_USER, DB_PASS); | |
| $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
| } catch(PDOException $e) { | |
| die("ERROR: Could not connect. " . $e->getMessage()); | |
| } | |
| // Set headers for API | |
| header("Content-Type: application/json; charset=UTF-8"); | |
| header("Access-Control-Allow-Origin: *"); | |
| header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE"); | |
| header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"); | |
| // JWT Secret key | |
| define('JWT_SECRET', 'your_secret_key_here'); | |
| ``` |