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方法

<form action="action/actiontest" method="get">
	<input type="text" name="name" placeholder="姓名"/>
	<input type="text" name="age" placeholder="年龄"/>
	<input type="submit" name="" id="" value="goActions" />
</form>

JST模块测试

    定义JST方法

extern int outputmytable(int ejid, Webs *wp, int argc, char **argv)
{
	websWrite(wp, "<tr>");
	websWrite(wp, "<td>CH340</td>");
	websWrite(wp, "<td>115200</td>");
	websWrite(wp, "<td>8</td>");
	websWrite(wp, "<td>1</td>");
	websWrite(wp, "<td>0</td>");
	websWrite(wp, "</tr>");
}

    注册JST方法

websDefineJst("outputmytable", outputmytable);

    测试JST方法

<table border="1" cellpadding="5" cellspacing="0" id="mytable">
		<caption style="font-weight: bold;">串口状态</caption>
		<tr>
			<th width="20%">线路协议</th>
			<th width="20%">波特率</th>
			<th width="20%">数据位</th>
			<th width="20%">起始位</th>
			<th width="20%">停止位</th>
		</tr>
		<%outputmytable();%>
</table>

 

配置文件: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页面所在目录

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值