SQL alchemy database access and show in html page in python

SQL alchemy database access and show in html page in python

Postby falcon007 » Sun Oct 13, 2013 10:55 am

I have a database with some entry. In my web application I log in with a page and show the corrosponding entries for that user on another page. I am using Jinja werkzueg for my light weight example. And using SQL alchemy.

Here is my code for showing the password list on the app.py file.

Code: Select all
class Passwordlist(flask.views.MethodView):
    def get(self):
        return flask.render_template('Password_list.html')
    def post(self):
        return flask.redirect(flask.url_for('listpassword'))

Then in my show page I want to list the details for that user. The data base connectivity is already tested with the following code.

Code: Select all
myuser = "admin"
mainuser = User.query.filter_by(username=myuser).first()
assert mainuser is not None
for w in Website.query.filter_by(user=mainuser):
    print "{0}: '{1}' '{2}'".format(w.id, w.urlusername, w.note)

This code works on my terminal run.

I need some idea how to implement it on the html page. I need the coding idea for the html page and for the
class Passwordlist(flask.views.MethodView):

Thank you.
Last edited by micseydel on Sun Oct 13, 2013 5:57 pm, edited 1 time in total.
Reason: First post lock, fixed code tags.
Posts: 1
Joined: Sun Oct 13, 2013 10:48 am

Return to Web Development

Who is online

Users browsing this forum: No registered users and 3 guests