I want to display my log.txt in my log.html. For some reason my page is completely blank. And I dont get to see anything from my file. Code:
def log():
with open("logs.txt", "r") as f:
content = f.read()
return render_template('log.html', content=content)
HTML LOG TEMPLATE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Log</title>
<link rel="stylesheet" href="/static/styles/nav.css" />
<link rel="stylesheet" href="/static/styles/basiclayout.css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<style>
</style>
<body>
<ul class="nav">
<li ><a href="{{ url_for('hello_world') }}" >Home</a></li>
<li ><a href="{{ url_for('notepad') }}">Notepad</a></li>
<li ><a href="{{ url_for('explorer') }}">Explorer </a></li>
<li class="active"><a href="{{ url_for('log') }}">Log </a></li>
<li ><a href="{{ url_for('upload') }}">Upload </a></li>
<li ><a href="{{ url_for('uploads') }}">Uploads </a></li>
<li ><a href="{{ url_for('logout') }}">Logout</a></li>
</ul>
<div class="alert">
{% for message in get_flashed_messages() %}
{{ message }}
{% endfor %}
</div>
<pre>{{ content }}</pre>
</body>
</html>
Added my HTML Template now.
Create a simple HTML page to display text. create a route ”/” and return home. html from the function. Then run your api.py file and click on the link that it provides after running.
return Response(content, mimetype='text/plain')
but really you probably want to use something like logstash...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With