goahead-4.0.2

源码下载

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/

交叉编译(使用Makeme)

    Makeme安装

  • make boot
  • sudo make install

    goahead交叉编译

  • CC=/xxxx/bin/mipsel-linux-gcc CFLAGS=-I/xxxx/include LDFLAGS=-L/xxxx/lib ./configure --platform linux-mips --without ssl
  • me

action模块测试

    定义action方法

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);
}

    注册action方法

websDefineAction("actiontest", myactiontest);

    测试action方法

JST模块测试

    定义JST方法

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, "");
}

    注册JST方法

websDefineJst("outputmytable", outputmytable);

    测试JST方法


		<%outputmytable();%>
串口状态
线路协议 波特率 数据位 起始位 停止位

 

配置文件:route.txt

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页面所在目录

 

 

你可能感兴趣的:(goahead-4.0.2)