## 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)
~~~
- 序言
- 安装
- 可视化编辑器
- woo 命令行参数详解
- 测试用例
- 简单http服务
- 正则
- gpio控制硬件设备
- 比武不招亲
- 和php比WebServer
- woo语法
- 语法简介
- 基本语法
- woo数据类型
- woo变量
- woo循环
- woo流程控制
- woo函数
- woo运算符
- woo字符串
- 类
- 类的继承
- 模块
- 数组
- 迭代
- table
- 元表(魔术方法)
- 错误处理
- 面向对象
- woo开发必须注意事项
- 函数/模块
- 内置函数
- webServer专属函数
- 内置模块
- gd-2d绘图库
- 2D图形例子
- websockets用例
- buffer缓存
- http
- orm数据库连接
- redis-ssdb连接
- queue队列
- 其他特别函数
- sockets
- 启动线程如何
- Murphy-http Web框架
- 简介
- 全局函数
- model
- view
- controller
- 消息队列
- 全局线程锁
- 包管理器/coder wooyri package manager
- 最ok的包上榜名单
- woo栗子
- 函数传参
- 编码解码
- http模块用例
- 移动读写文件流用例
- 文件下载用例
- 数组迭代
- 进制转换
- _choose用例
- 日期时间用例
- 注明
- wop 码包|coder wooyri peogram
- 码人激励计划