Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- simple.py
- import web
- import json, urllib.request, requests
- from datetime import datetime
- from time import sleep
- now = datetime.now
- url = "https://datahead.herokuapp.com/api/employeers/"
- response = urllib.request.urlopen(url)
- data = json.loads(response.read())
- for i in data:
- print('\n')
- for key, value in i.items():
- print(key,':', value)
- # Server running
- urls = ('/', 'index')
- render = web.template.render('templates/')
- # employes data
- class index:
- def GET(self):
- return render.index(data)
- if __name__ == "__main__":
- app = web.application(urls, globals())
- print("\n\nrunning")
- app.run()
- index.html
- $def with (data)
- <title>Home Page</title>
- <!-- DataTables Example -->
- <div style="margin:0 auto;width:85%;text-align:left" class="card mb-3">
- <div class="card-body">
- <div class="table-responsive">
- <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
- <thead>
- <tr>
- <th>Record ID</th>
- <th>Name</th>
- <th>Log Date</th>
- <th>Login</th>
- <th>Logout</th>
- </tr>
- </thead>
- <tfoot>
- <tr>
- <th>Record ID</th>
- <th>Name</th>
- <th>Log Out</th>
- <th>Login</th>
- <th>Logout</th>
- </tr>
- </tfoot>
- $for i in data:
- <tbody>
- <tr>
- <td>$i</td>
- </tr>
- <tbody>
- </table>
- </div>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement