企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## PS:这里的http服务可以有多种形式: # 1.第一种形式,使用命令启动对目录的访问: > 一下命令启动了一个简单的http服务,目录地址为`/user/local/http_dir` > 地址为8008,-cc表示启动缓存代码,所有的代码只会被加载一次 > -s 加与不加都可,不加,则目录参数放到第一个即可 > 也可以加入-ia index.woo表示所有请求都进入index.woo文件内处理 ## `woo -s /user/local/http_dir -t http -p 8008 -cc 1 -i index.html` # 2.第二种形式,使用命令启动单个文件的httpserver: > 1.单个文件内在头部使用--CONF来定义输入参数 > 2.文件内的参数会被控制台参数覆盖,比如`woo -p 6666` 会覆盖文件内定义的8005端口 ## .)单个文件`http-single-file.woo`内容如下: ~~~woo --CONF:--type http --CONF:--index index.woo --CONF:--index_all 1 --CONF:--port 8005 --CONF:--cache_code 1 _out("run args:", _args(), '\n') local a1, b2 = _http_params("a1", 'b2') _out('a1:', a1, '\nb2:', b2) _out('\n\npath:', _http_request('path')) _out('\nhost:', _http_request('host')) _out('\nuri:', _http_request('uri')) ~~~ ## 启动执行:`woo http-single-file.woo`,所有的请求htttpweb请求都会被这一个文件处理 # 3.第三种形式,使用命令启动单个文件的httpserver: 单个文件 http-single-file.woo 内容: ~~~woo _out("run args:", _args(), '\n') local a1, b2 = _http_params("a1", 'b2') _out('a1:', a1, '\nb2:', b2) _out('\n\npath:', _http_request('path')) _out('\nhost:', _http_request('host')) _out('\nuri:', _http_request('uri')) ~~~ ## 启动:`woo http-single-file.woo -t http -p 8008 -ia 1 -i index.woo` # 4.第四种形式,使用命令启动httpserver(不需要文件参与): ~~~woo woo.exe -r "woo.http:new():listen(':8000','_out(\'hello world!\')')" ~~~ # 5.同上,使用命令启动httpserver(不需要文件参与): ~~~lua local a=[[ local path=_http_request('path') local uri=_http_params('uri') _out(path) ]] woo.http:new():listen(':8008',a) ~~~