Update test.py

This commit is contained in:
MattTheTekie 2023-10-06 08:51:01 -04:00 committed by GitHub
commit 7b8df1ed7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

11
test.py
View file

@ -51,7 +51,7 @@ def blog(filename):
@app.route('/blogquest')
def blogquest():
blog_links = []
blog_data = []
# Iterate through files in the "blogs" folder
for filename in os.listdir(blog_folder):
@ -69,9 +69,14 @@ def blogquest():
if title_start != -1 and title_end != -1 and author_start != -1 and author_end != -1:
blog_title = html_content[title_start:title_end]
author_name = html_content[author_start:author_end]
blog_links.append(f'<a href="/blog/{filename}">{blog_title} by {author_name}</a>')
blog_data.append({
'title': blog_title,
'author': author_name,
'url': f"/blog/{filename}"
})
return render_template('blogquest.html', blogs=blog_data)
return "<br>".join(blog_links)
if __name__ == '__main__':
app.run(debug=True, port=8162)