35 lines
963 B
PHP
35 lines
963 B
PHP
<?php
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Route;
|
|
use App\Http\Controllers\WebCrawlController;
|
|
|
|
Route::get('/crawl', function (Request $request) {
|
|
$url = $request->query('url');
|
|
|
|
if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) {
|
|
return response()->json([
|
|
'error' => 'Missing required parameter `url` or invalid URL',
|
|
], 400);
|
|
}
|
|
|
|
$depth = $request->query('depth', 3);
|
|
|
|
$crawlerController = new WebCrawlController();
|
|
return $crawlerController->crawlWebsite($request);
|
|
});
|
|
|
|
Route::get('/', function () {
|
|
$crawlerController = new WebCrawlController();
|
|
return $crawlerController->index();
|
|
});
|
|
|
|
Route::delete('/crawl/{id}', function ($id) {
|
|
$crawlerController = new WebCrawlController();
|
|
return $crawlerController->destroy($id);
|
|
});
|
|
|
|
Route::delete('/crawl', function () {
|
|
$crawlerController = new WebCrawlController();
|
|
return $crawlerController->destroyAll();
|
|
});
|