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:
JavaScript
x
5
1
def log():
2
with open("logs.txt", "r") as f:
3
content = f.read()
4
return render_template('log.html', content=content)
5
HTML LOG TEMPLATE:
JavaScript
1
38
38
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="UTF-8">
5
<title>Log</title>
6
<link rel="stylesheet" href="/static/styles/nav.css" />
7
<link rel="stylesheet" href="/static/styles/basiclayout.css" />
8
<meta name="viewport" content="width=device-width, initial-scale=1">
9
</head>
10
<style>
11
12
13
</style>
14
<body>
15
<ul class="nav">
16
<li ><a href="{{ url_for('hello_world') }}" >Home</a></li>
17
<li ><a href="{{ url_for('notepad') }}">Notepad</a></li>
18
<li ><a href="{{ url_for('explorer') }}">Explorer </a></li>
19
<li class="active"><a href="{{ url_for('log') }}">Log </a></li>
20
<li ><a href="{{ url_for('upload') }}">Upload </a></li>
21
<li ><a href="{{ url_for('uploads') }}">Uploads </a></li>
22
<li ><a href="{{ url_for('logout') }}">Logout</a></li>
23
24
25
26
</ul>
27
<div class="alert">
28
{% for message in get_flashed_messages() %}
29
{{ message }}
30
{% endfor %}
31
</div>
32
33
<pre>{{ content }}</pre>
34
35
36
</body>
37
</html>
38
Added my HTML Template now.
Advertisement
Answer
JavaScript
1
2
1
return Response(content, mimetype='text/plain')
2
but really you probably want to use something like logstash…