Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. simple.py
  2.  
  3. import web
  4. import json, urllib.request, requests
  5. from datetime import datetime
  6. from time import sleep
  7.  
  8.  
  9. now = datetime.now
  10. url = "https://datahead.herokuapp.com/api/employeers/"
  11. response = urllib.request.urlopen(url)
  12. data = json.loads(response.read())
  13.  
  14. for i in data:
  15. print('\n')
  16. for key, value in i.items():
  17. print(key,':', value)
  18.  
  19. # Server running
  20. urls = ('/', 'index')
  21. render = web.template.render('templates/')
  22.  
  23. # employes data
  24.  
  25. class index:
  26. def GET(self):
  27. return render.index(data)
  28.  
  29. if __name__ == "__main__":
  30. app = web.application(urls, globals())
  31. print("\n\nrunning")
  32. app.run()
  33.  
  34.  
  35. index.html
  36.  
  37. $def with (data)
  38.  
  39. <title>Home Page</title>
  40.  
  41.  
  42. <!-- DataTables Example -->
  43. <div style="margin:0 auto;width:85%;text-align:left" class="card mb-3">
  44. <div class="card-body">
  45. <div class="table-responsive">
  46. <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
  47.  
  48.  
  49. <thead>
  50. <tr>
  51. <th>Record ID</th>
  52. <th>Name</th>
  53. <th>Log Date</th>
  54. <th>Login</th>
  55. <th>Logout</th>
  56. </tr>
  57. </thead>
  58. <tfoot>
  59. <tr>
  60. <th>Record ID</th>
  61. <th>Name</th>
  62. <th>Log Out</th>
  63. <th>Login</th>
  64. <th>Logout</th>
  65. </tr>
  66. </tfoot>
  67.  
  68. $for i in data:
  69.  
  70. <tbody>
  71. <tr>
  72. <td>$i</td>
  73.  
  74. </tr>
  75. <tbody>
  76.  
  77. </table>
  78. </div>
  79. </div>
  80. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement