浏览代码

submit some demo

lusa 5 年之前
父节点
当前提交
795e949ce9
共有 39 个文件被更改,包括 131 次插入3 次删除
  1. 1 1
      app/Makefile
  2. 二进制
      app/goahead-5.1.0/build/linux-arm-static/.install-certs-modified
  3. 二进制
      app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test
  4. 二进制
      app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test.gdb
  5. 二进制
      app/goahead-5.1.0/build/linux-arm-static/bin/goahead.gdb
  6. 二进制
      app/goahead-5.1.0/build/linux-arm-static/bin/gopass
  7. 二进制
      app/goahead-5.1.0/build/linux-arm-static/bin/gopass.gdb
  8. 二进制
      app/goahead-5.1.0/build/linux-arm-static/bin/libgo.a
  9. 二进制
      app/goahead-5.1.0/build/linux-arm-static/bin/libgoahead-mbedtls.a
  10. 二进制
      app/goahead-5.1.0/build/linux-arm-static/bin/libmbedtls.a
  11. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/action.o
  12. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/alloc.o
  13. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/auth.o
  14. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/cgi.o
  15. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/crypt.o
  16. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/file.o
  17. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/fs.o
  18. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/goahead-mbedtls.o
  19. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/goahead.o
  20. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/gopass.o
  21. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/http.o
  22. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/js.o
  23. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/jst.o
  24. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/mbedtls.o
  25. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/options.o
  26. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/osdep.o
  27. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/rom.o
  28. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/route.o
  29. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/runtime.o
  30. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/socket.o
  31. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/test.o
  32. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/time.o
  33. 二进制
      app/goahead-5.1.0/build/linux-arm-static/obj/upload.o
  34. 2 0
      app/goahead-5.1.0/src/action.c
  35. 91 0
      app/goahead-5.1.0/src/goahead.c
  36. 36 1
      app/goahead-5.1.0/src/web/index.html
  37. 0 0
      app/goahead-5.1.0/src/web/static/js/app.js
  38. 0 0
      app/goahead-5.1.0/src/web/static/js/chunk-vendors.js
  39. 1 1
      local/rc

+ 1 - 1
app/Makefile

@@ -1,5 +1,5 @@
 all	: 
 all	: 
-	make -C ./web
+	make -C ./goahead-5.1.0
 #	apps modules test_apps
 #	apps modules test_apps
 clean	: clean_apps clean_modules clean_test_apps
 clean	: clean_apps clean_modules clean_test_apps
 
 

二进制
app/goahead-5.1.0/build/linux-arm-static/.install-certs-modified


二进制
app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test


二进制
app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test.gdb


二进制
app/goahead-5.1.0/build/linux-arm-static/bin/goahead.gdb


二进制
app/goahead-5.1.0/build/linux-arm-static/bin/gopass


二进制
app/goahead-5.1.0/build/linux-arm-static/bin/gopass.gdb


二进制
app/goahead-5.1.0/build/linux-arm-static/bin/libgo.a


二进制
app/goahead-5.1.0/build/linux-arm-static/bin/libgoahead-mbedtls.a


二进制
app/goahead-5.1.0/build/linux-arm-static/bin/libmbedtls.a


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/action.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/alloc.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/auth.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/cgi.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/crypt.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/file.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/fs.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/goahead-mbedtls.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/goahead.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/gopass.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/http.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/js.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/jst.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/mbedtls.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/options.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/osdep.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/rom.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/route.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/runtime.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/socket.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/test.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/time.o


二进制
app/goahead-5.1.0/build/linux-arm-static/obj/upload.o


+ 2 - 0
app/goahead-5.1.0/src/action.c

@@ -119,6 +119,8 @@ PUBLIC void websFooter(Webs *wp)
 }
 }
 #endif
 #endif
 
 
+
+
 /*
 /*
     Copyright (c) Embedthis Software. All Rights Reserved.
     Copyright (c) Embedthis Software. All Rights Reserved.
     This software is distributed under commercial and open source licenses.
     This software is distributed under commercial and open source licenses.

+ 91 - 0
app/goahead-5.1.0/src/goahead.c

@@ -38,10 +38,94 @@ static LRESULT CALLBACK websWindProc(HWND hwnd, UINT msg, UINT wp, LPARAM lp);
 static void sigHandler(int signo);
 static void sigHandler(int signo);
 #endif
 #endif
 
 
+static void buy(Webs *wp);
+static void actionTest(Webs *wp);
+static void personInfoAction(Webs *wp);
+
+
+typedef struct PERSON
+{
+  char *name;
+  int age;
+  char *gender;
+}Person;
+
+
+
+static void personInfoAction(Webs *wp)
+{
+    logmsg(2, "-----------------------111----------------------");
+    int i; 
+    Person person[2];
+    person[0].name = "kangkang";
+    person[0].age = 12;
+    person[0].gender = "male";
+    person[1].name = "Jane";
+    person[1].age = 14;
+    person[1].gender = "female";
+
+   websSetStatus(wp, 200);
+   websWriteHeaders(wp, -1, 0);
+   websWriteEndHeaders(wp);
+
+    websWrite(wp, "[");
+     for (i = 0;i < 2; i++)
+     {
+      
+      websWrite(wp, "       {\"name\":\"%s\",\"age\":\"%d\",\"gender\":\"%s\"}",
+       person[i].name, person[i].age, person[i].gender);
+      if (i != 1)
+      {
+       websWrite(wp, ",");
+      }
+      
+     }
+     websWrite(wp, "]");
+     websDone(wp);
+}
+
+
+static void buy(Webs *wp)
+{
+    char    *name, *age;
+    name = websGetVar(wp, "name", NULL);
+    age = websGetVar(wp, "age", NULL);
+     logmsg(2, "---------------------------------------------");
+    logmsg(2, "name value is : %s", name );
+     logmsg(2, "age value is : %s", age );
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, 0, 0);
+    websWriteEndHeaders(wp);
+    websWrite(wp, "Name %s", name); 
+    websWrite(wp,  "Age %s", age);
+    websFlush(wp, 0);
+    websDone(wp);
+}
+
+
+
+/*
+    Implement /action/actionTest. Parse the form variables: name, address and echo back.
+ */
+static void actionTest(Webs *wp)
+{
+    cchar   *name, *address;
+
+    name = websGetVar(wp, "name", NULL);
+    address = websGetVar(wp, "address", NULL);
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp);
+    websWrite(wp, "<html><body><h2>name: %s, address: %s</h2></body></html>\n", name, address);
+    websFlush(wp, 0);
+    websDone(wp);
+}
+
 /*********************************** Code *************************************/
 /*********************************** Code *************************************/
 
 
 MAIN(goahead, int argc, char **argv, char **envp)
 MAIN(goahead, int argc, char **argv, char **envp)
 {
 {
+   
     char    *argp, *home, *documents, *endpoints, *endpoint, *route, *auth, *tok, *lspec;
     char    *argp, *home, *documents, *endpoints, *endpoint, *route, *auth, *tok, *lspec;
     int     argind;
     int     argind;
 	logmsg(2, "---> log1\n");
 	logmsg(2, "---> log1\n");
@@ -151,6 +235,13 @@ MAIN(goahead, int argc, char **argv, char **envp)
      */
      */
     websAddRoute("/", "file", 0);
     websAddRoute("/", "file", 0);
 #endif
 #endif
+
+//add by lusa start 
+        websDefineAction("buy", buy);
+        websDefineAction("test", actionTest);
+        websDefineAction("person", personInfoAction);
+        
+// add by lusa end 
 #ifdef GOAHEAD_INIT
 #ifdef GOAHEAD_INIT
     /*
     /*
         Define your init function in main.me goahead.init, or
         Define your init function in main.me goahead.init, or

+ 36 - 1
app/goahead-5.1.0/src/web/index.html

@@ -1 +1,36 @@
-<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>bmc-ui</title><link href=/static/css/app.css rel=preload as=style><link href=/static/js/app.js rel=preload as=script><link href=/static/js/chunk-vendors.js rel=preload as=script><link href=/static/css/app.css rel=stylesheet></head><body><noscript><strong>We're sorry but bmc-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/static/js/chunk-vendors.js></script><script src=/static/js/app.js></script></body></html>
+ <p>Please log in</p>
+    <form action=/action/test method="post">
+        <table>
+        <tr><td>账号:</td><td><input type="text" name="name"></td></tr>
+        <tr><td>密码:</td><td><input type="password" name="address"></td></tr>
+        <tr><td><input type="submit" name="submit" value="submit"></td>
+            <td><input type="reset" value="reset"></td></tr>
+        </table>
+    </form>
+    
+    <script type="text/javascript">
+    function loadXMLDoc()
+    {
+        var xmlhttp;
+        if (window.XMLHttpRequest)
+          {// code for IE7+, Firefox, Chrome, Opera, Safari
+              xmlhttp=new XMLHttpRequest();
+          }
+        else
+          {// code for IE6, IE5
+              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
+          }
+        xmlhttp.onreadystatechange=function()
+          {
+              if (xmlhttp.readyState==4 && xmlhttp.status==200)
+            {
+                document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
+                }
+          }
+        xmlhttp.open("GET","action/test",true);
+        xmlhttp.send();
+    }
+    </script>
+    
+    <div id="myDiv"><h2>需要刷新的局部内容</h2></div>
+    <button type="button" onclick="loadXMLDoc()">通过 AJAX 实现局部刷新</button>

文件差异内容过多而无法显示
+ 0 - 0
app/goahead-5.1.0/src/web/static/js/app.js


文件差异内容过多而无法显示
+ 0 - 0
app/goahead-5.1.0/src/web/static/js/chunk-vendors.js


+ 1 - 1
local/rc

@@ -9,4 +9,4 @@ ifconfig lo 127.0.0.1
 
 
 #run bmc function 
 #run bmc function 
 #./usr/bin/bmc.sh 
 #./usr/bin/bmc.sh 
-
+/usr/bin/goahead -v --home /etc/goahead /var/www/goahead &

部分文件因为文件数量过多而无法显示