2023-12-12 20:25:41 +00:00
|
|
|
<?php
|
2023-12-18 15:08:52 +00:00
|
|
|
// require autoloader
|
2023-12-12 20:25:41 +00:00
|
|
|
require('./autoloader.php');
|
|
|
|
|
|
|
|
use urlManipulator\UrlManipulator;
|
|
|
|
|
2023-12-18 15:08:52 +00:00
|
|
|
// 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);
|
2023-12-18 15:08:52 +00:00
|
|
|
// send the result as a JSON response
|
2023-12-12 20:25:41 +00:00
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|