update the script

main
vitrinekast 10 months ago
parent d0758a984c
commit b8e3c940d0

@ -1,4 +1,4 @@
q
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
## Getting the data ## Getting the data
@ -6,9 +6,9 @@ import subprocess
#subprocess.run(["ls", "-l"]) #subprocess.run(["ls", "-l"])
#print(os.popen("ls -l").read()) #print(os.popen("ls -l").read())
thing = subprocess.run(["uptime", "-p"], capture_output=True) uptime = subprocess.run(["uptime", "-p"], capture_output=True)
print(thing.stdout) #print(thing.stdout)
last_here = subprocess.run(["last", "-s", "today"], capture_output=True)
## Creating the HTML ## Creating the HTML
# loading the environment # loading the environment
@ -18,7 +18,7 @@ env = Environment(loader = FileSystemLoader('templates'))
template = env.get_template('template.jinja') template = env.get_template('template.jinja')
# rendering the template and storing the resultant text in variable output # rendering the template and storing the resultant text in variable output
output = template.render(uptime = thing.stdout) output = template.render(uptime = uptime.stdout, last_here=last_here.stdout)
# printing the output on screen # printing the output on screen
print(output) print(output)

@ -7,5 +7,8 @@
</head> </head>
<body> <body>
<h1>I am a HTML page fillllllled with data, such as the {{ uptime }}</h1> <h1>I am a HTML page fillllllled with data, such as the {{ uptime }}</h1>
<p>Or say something about who was here?</p>
<pre>{{ last_here }}</pre>
</body> </body>
</html> </html>

Loading…
Cancel
Save