goahead源码 |
git clone http://github.com/embedthis/goahead |
https://www.embedthis.com/goahead/ |
Makeme源码 |
git clone https://github.com/embedthis/makeme.git |
https://www.embedthis.com/makeme/ |
static void myactiontest(Webs *wp)
{
char *name = websGetVar(wp, "name", "");
char *age = websGetVar(wp, "age", "");
char writedata[128];
int length = 0;
if(strlen(name)<1 || strlen(age)<1)
{
length = snprintf(writedata, sizeof(writedata), "name or age is NULL, please check !!!");
}
else
{
length = snprintf(writedata, sizeof(writedata), "name = %s, age = %s", name, age);
}
websSetStatus(wp, 200);
websWriteHeaders(wp, length, 0);
websWriteEndHeaders(wp);
websWrite(wp, writedata);
websDone(wp);
}
websDefineAction("actiontest", myactiontest);
extern int outputmytable(int ejid, Webs *wp, int argc, char **argv)
{
websWrite(wp, "");
websWrite(wp, "CH340 ");
websWrite(wp, "115200 ");
websWrite(wp, "8 ");
websWrite(wp, "1 ");
websWrite(wp, "0 ");
websWrite(wp, " ");
}
websDefineJst("outputmytable", outputmytable);
串口状态
线路协议
波特率
数据位
起始位
停止位
<%outputmytable();%>
route uri=/cgi-bin dir=cgi-bin handler=cgi //cgi方法请求的路径
route uri=/action handler=action //action方法
route uri=/ extensions=jst,asp,html handler=jst //可以使用jst方法页面的声明
route uri=/ methods=OPTIONS|TRACE handler=options
# For legacy GoAhead applications using /goform
route uri=/goform handler=action
编译完成后在 build/linux-mips-debug/bin 目录产生可执行文件和链接库,将 src 目录下的 auth.txt 、route.txt 和 web 拷贝到该目录,交叉编译情况下将这些文件拷贝到板子上即可
sudo ./goahead -v --home PATH1 PATH2
-v : 打开运行日志
--home : 指定运行目录, 第一个参数 PATH1 是配置文件的所在目录 第二个参数 PATH2 是web页面所在目录