-
-
Save jennielees/1a5b65edf983fa299393 to your computer and use it in GitHub Desktop.
App with controller notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template | |
app = Flask(__name__) | |
from models import * # Import the database methods we created in models.py | |
@app.route('/') | |
def show_index_page(): | |
### Show an index page offering the option to Sign Up or Log In | |
@app.route('/login') | |
def show_login_page(): | |
### Show the login page | |
@app.route('/submit-login', methods=['POST']) | |
def submit_login_form(): | |
### Submit the login form | |
### Get the user from the database matching the submitted username | |
### Check the password matches | |
### Redirect to logged-in page | |
@app.route('/signup') | |
def show_signup_page(): | |
### Show the signup page | |
@app.route('/submit-signup', methods=['POST']) | |
def submit_signup_form(): | |
### Submit the signup form | |
### Check the user entered everything they were supposed to | |
### Check the username doesn't already exist | |
### Create a new user with the provided information | |
### Redirect to logged-in page | |
@app.route('/logged-in') | |
def show_logged_in_page(): | |
### Show a placeholder page that only displays when you have logged in | |
@app.route('/admin') | |
def list_all_users(): | |
### Get a list of all users from the database | |
### Show a list of all the users (admin page) | |
### You can expand this by creating a single view that shows an | |
### individual user's details when you click on it. | |
if __name__=='__main__': | |
app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment