UrlManipulator-php/server/index.php

15 lines
405 B
PHP
Raw Normal View History

2023-12-12 20:25:41 +00:00
<?php
// require autoloader
2023-12-12 20:25:41 +00:00
require('./autoloader.php');
use urlManipulator\UrlManipulator;
// handle POST requests
2023-12-12 20:25:41 +00:00
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$urlManipulator = new UrlManipulator();
$url = $_POST['url'];
$result = $urlManipulator->manipulateUrl($url);
// send the result as a JSON response
2023-12-12 20:25:41 +00:00
header('Content-Type: application/json');
echo json_encode($result);
}