-1

I am currently stuck in connecting a function into my flask web app and need so guidance on how to do so.

I have made a function and (it works perfectly) that takes in a parameter and it will print out a list of items. Example of usage is

studentatt('15000001')
will print the content that 15000000 have in a database.

A segment of code from my flask app contains

from flask_login import current_user, login_user, logout_user, login_required
from app.models import User


from mySQL import studentatt

@app.route('/user/<username>')
@login_required
def user(username):
    user = User.query.filter_by(username=username).first_or_404()


return render_template('user.html', user=user)

Whats in the databse for the user is that

class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True, unique=True)
    studentId = db.Column(db.Integer(), index=True, unique=True)
    email = db.Column(db.String(120), index=True, unique=True)

The question is how do I use my imported function and how do I extract the studentId data from the database to plug in to the function that I can store the date to the render_template to display in the web browser.

Han
  • 101
  • 14

1 Answers1

0

Solve it by using current_user.studentId

Han
  • 101
  • 14