Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 2 gadiem
pirms 3 gadiem
pirms 2 gadiem
pirms 2 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # @name: main.py
  2. # @creation_date: 2021-10-20
  3. # @license: The MIT License <https://opensource.org/licenses/MIT>
  4. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  5. # @purpose: Main route for index and other pages
  6. # @acknowledgements:
  7. # https://www.digitalocean.com/community/tutorials/how-to-add-authentication-to-your-app-with-flask-login
  8. from flask import Blueprint, render_template
  9. from flask_login import login_required, current_user
  10. from .models import Resource
  11. from .resources import *
  12. from sqlalchemy.sql import func
  13. import markdown
  14. main = Blueprint('main', __name__)
  15. # route for index page
  16. @main.route('/')
  17. def index():
  18. tools = Resource.query.filter_by(type='tool').order_by(func.random()).limit(6).all()
  19. with open('content/home.md', 'r') as f:
  20. text = f.read()
  21. text = markdown.markdown(text)
  22. book_showcase = get_book('69')
  23. return render_template('index.html', text=text, tools=tools, book=book_showcase)
  24. # route for profile page
  25. @main.route('/profile')
  26. @login_required
  27. def profile():
  28. return render_template('profile.html', name=current_user.name)
  29. # route for test page
  30. @main.route('/test')
  31. def test():
  32. return render_template('test.html')
  33. # route for about page
  34. @main.route('/about')
  35. def about():
  36. with open('content/about.md', 'r') as f:
  37. text = f.read()
  38. text = markdown.markdown(text)
  39. return render_template('about.html', text=text)