$http = new swoole_http_server("0.0.0.0", 9501); $http->set( [ 'enable_static_handler'=>true, 'document_root'=>'/data/apps/operation/abc' ] ); $http->on('request', function ($request, $response) { $response->end("<h1>Hello Swoole. #".rand(1000, 9999)."</h1>".json_encode($request->get)); }); $http->start();
http直接访问index.html
最新推荐文章于 2026-04-28 06:06:28 发布
本文介绍使用Swoole在本地快速搭建一个HTTP服务器的方法。通过设置服务器监听地址及端口,启用静态文件处理,并指定根目录。演示了如何响应客户端请求并返回带有随机数的欢迎消息。

8713

被折叠的 条评论
为什么被折叠?



