backend.html 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="apple-mobile-web-app-capable" content="yes" />
  5. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  6. <meta charset="UTF-8">
  7. <meta name="theme-color" content="#4b75ff">
  8. <link rel="stylesheet" href="../script/semantic/semantic.min.css">
  9. <script src="../script/jquery.min.js"></script>
  10. <script src="../script/ao_module.js"></script>
  11. <script src="../script/semantic/semantic.min.js"></script>
  12. <title>ao_backend Test</title>
  13. </head>
  14. <body>
  15. <br><br>
  16. <div class="ui container">
  17. <h2>ao_backend Testing Interface</h2>
  18. <p>See console for more information</p>
  19. </div>
  20. <!-- <script src="ao_backend.js"></script> -->
  21. <script>
  22. //Register the backend wrapper path
  23. var backendWrapper = ao_module_backend();
  24. backendWrapper.start("UnitTest/ao_backend.js");
  25. //Test appdata
  26. backendWrapper.appdata.readFile("UnitTest/appdata.txt", function(content){
  27. console.log(content);
  28. });
  29. backendWrapper.appdata.listDir("UnitTest/", function(list){
  30. console.log(list);
  31. });
  32. //Test File operation
  33. backendWrapper.file.readdir("user:/Desktop/", function(files){
  34. console.log(files);
  35. });
  36. //Try file read write
  37. backendWrapper.file.writeFile("user:/Desktop/hello.txt", "Hello World!",function(data){
  38. console.log("Write File: ", data);
  39. });
  40. backendWrapper.file.readFile("user:/Desktop/hello.txt",function(content){
  41. console.log("Read File: " + content);
  42. });
  43. backendWrapper.file.mtime("user:/Desktop/hello.txt",function(data){
  44. console.log("Test file mtime", data);
  45. });
  46. backendWrapper.file.isDir("user:/Desktop/hello.txt",function(data){
  47. console.log("Test file is Dir", data);
  48. });
  49. backendWrapper.file.filesize("user:/Desktop/hello.txt",function(data){
  50. console.log("Test file size", data, " bytes");
  51. });
  52. backendWrapper.file.aglob("user:/Desktop/*.mp3",undefined, function(data){
  53. console.log("mp3 on desktop: ", data);
  54. });
  55. //http test
  56. backendWrapper.http.download("https://ccns.arozos.com/share/download/6341f7fe-e03e-4200-88f2-6d4800b846fc/imuslab%20%E4%B8%BB%E9%A1%8C%E6%9B%B2.mp3", "tmp:/", "", function(data){
  57. console.log("Download status: ", data)
  58. });
  59. backendWrapper.http.get("https://www.google.com/robots.txt", function(data){
  60. console.log("HTTP GET test: ", data);
  61. })
  62. backendWrapper.http.post("https://www.google.com/robots.txt", undefined, function(data){
  63. console.log("HTTP POST test: ", data);
  64. })
  65. </script>
  66. </body>
  67. </html>