Skip to content

Instantly share code, notes, and snippets.

@ahmaddidiks
Created August 20, 2023 05:05
Show Gist options
  • Save ahmaddidiks/2c236212b5b6494a78c085a97fd9450e to your computer and use it in GitHub Desktop.
Save ahmaddidiks/2c236212b5b6494a78c085a97fd9450e to your computer and use it in GitHub Desktop.
Flask show table data
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Absensi Murid</h1>
<table id="demo">
{% for u in murid %}
<tr>
<td>{{ u[0] }}</td>
<td>{{ u[1] }}</td>
<td>{{ u[2] }}</td>
</tr>
{% endfor %}
</table>
</body>
</html>
from flask import Flask, render_template, Response
from datetime import datetime
app = Flask(__name__)
@app.route('/')
def index():
masuk = datetime.now().date()
keluar = datetime.now().date()
user = [['Nama', 'Masuk', 'Keluar']]
user.append(['Didik', masuk, keluar])
user.append(['Paijo', masuk, keluar])
return render_template('index.html', murid=user)
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment