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.

28 rindas
816B

  1. # @name: main.py
  2. # @version: 0.1
  3. # @creation_date: 2021-10-20
  4. # @license: The MIT License <https://opensource.org/licenses/MIT>
  5. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  6. # @purpose: Main route for index and other pages
  7. # @acknowledgements:
  8. # https://www.digitalocean.com/community/tutorials/how-to-add-authentication-to-your-app-with-flask-login
  9. from flask import Blueprint, render_template
  10. from flask_login import login_required, current_user
  11. from . import db
  12. from .models import Tool
  13. main = Blueprint('main', __name__)
  14. # route for index page
  15. @main.route('/')
  16. def index():
  17. tools = Tool.query.limit(3)
  18. return render_template('index.html', tools=tools)
  19. # route for profile page
  20. @main.route('/profile')
  21. @login_required
  22. def profile():
  23. return render_template('profile.html', name=current_user.name)