log.htmlにlog.txtを表示したい。 何らかの理由で私のページは完全に空白です。 私のファイルからは何も見ません。 コード:Python Flaskを使用してHTMLに.txtファイルを表示
def log():
with open("logs.txt", "r") as f:
content = f.read()
return render_template('log.html', content=content)
HTML LOGテンプレート:
<!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>
は今、私のHTMLテンプレートを追加しました。
**より良い**何を意味するのでしょうか? –
"log.html"の完全なテンプレートを投稿してください。あなたがここに表示した内容になり、あなたが私の答えにコメントとして追加したスクリーンショットになることはできませんので... –
あなたはJoranに行きます。 – Julian