Done with the samples, and can be released as first version!
This commit is contained in:
30
main.py
30
main.py
@ -43,7 +43,35 @@ def uni():
|
||||
|
||||
@app.route('/projects')
|
||||
def projects():
|
||||
return render_template('projects/projects.html')
|
||||
posts = []
|
||||
with open("posts.json", "r") as f:
|
||||
posts = json.load(f)
|
||||
|
||||
posts.reverse()
|
||||
return render_template('projects/projects.html', post_data=posts)
|
||||
|
||||
@app.route('/projects/search', methods=['GET', 'POST'])
|
||||
def search():
|
||||
searched = request.args.get('searched')
|
||||
searched = str(searched).lower()
|
||||
posts = []
|
||||
with open("posts.json", "r") as f:
|
||||
posts = json.load(f)
|
||||
posts.reverse()
|
||||
if searched == "":
|
||||
return render_template('projects/projects.html', post_data=posts)
|
||||
found = []
|
||||
for i in posts:
|
||||
if searched in [j.lower() for j in i['topics']] and i not in found:
|
||||
found.append(i)
|
||||
if searched in i['title'].lower() and i not in found:
|
||||
found.append(i)
|
||||
if searched in i['content'].lower() and i not in found:
|
||||
found.append(i)
|
||||
if searched in i['date'] and i not in found:
|
||||
found.append(i)
|
||||
|
||||
return render_template('projects/projects.html', post_data=found)
|
||||
|
||||
@app.route('/git')
|
||||
def git():
|
||||
|
Reference in New Issue
Block a user