[英]Add rest api with website
我剛剛為我的網站創建了一個苗條的REST API,並且我想圍繞同一域(服務器)創建我的網站。
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require '../vendor/autoload.php';
//require '../src/config/db.php';
$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello, $name");
return $response;
});
#Customer Routes
//require '../src/routes/customer.php';
$app->run();
?>
<!DOCTYPE html>
<html>
<head></head>
<body></body>
</html>
現在我的網頁沒有顯示,但是當我刪除html文本時,它可以正常運行。
我只希望我的Web服務(使用Slim API)和我的網站都在同一服務器上。 請幫忙。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.