Commits

Fran Peruzzi  committed e99bfa1 Draft

skeleton and action list for nicelist.py

  • Participants
  • Parent commits 9a8756f

Comments (0)

Files changed (1)

 import sqlite3
-from flask import Flask, g
+from flask import Flask, g, render_template, request, flash, redirect, url_for
 
 # configuration
 DATABASE = './nicelist.db'
 DEBUG = True
 SECRET_KEY = 'changeme'
 
+
 app = Flask(__name__)
 app.config.from_object(__name__)
 
     g.db.close()
 
 
+@app.route('/')
+def index():
+    # if the user is logged in, it will take them directly to their page,
+    # otherwise, it will take theme to the intro page
+    return render_template('index.html')
+
+
+def user_homepage():
+    # this is the user's page. If they are logged in, they will be taken here
+    # automatically.
+    return render_template('user_homepage.html')
+
+
+def intro():
+    # this is the front page of the site if you are not logged in when you get
+    # to the site
+    return render_template('intro.html')
+
+
+@app.route('/login', methods=['GET', 'POST'])
+def login():
+    # login page
+    # TODO: initialize the form
+    error = None
+    return render_template('login.html', error=error)
+
+
+@app.route('/logout')
+def logout():
+    # log out
+    # TODO: log the user out and destroy the session
+    return redirect(url_for('index'))
+
+
+@app.route('/sign_up', methods=['GET', 'POST'])
+def sign_up():
+    # sign up page
+    # TODO: initialize the form object
+    error = None
+    if request.methd == 'POST':
+        # TODO: process the entry values and redirect to the user_homepage
+        # if there are no errors
+        flash('You were logged in successfully')
+        return redirect(url_for('user_homepage'))
+    return render_template('login.html', error=error)
+
+
+@app.route('/settings', method=['GET', 'POST'])
+def settings():
+    # this is the user's settings page
+    # TODO: initialize the form object
+    error = None
+    msg = ''
+    if request.method == 'POST':
+        # TODO: process the entry values and flash a success or failure message
+        flash(msg)
+    return render_template('settings.html', error=error)
+
+
+@app.route('/<user_id>')
+def user_page(user_id):
+    # this is the page when you go to someone else's list
+    # TODO: get the information for the page from the database
+    return render_template('user.html')
+
+
+# TODO: need to create the API functions to add, edit, and delete user list
+# entries
+
+# TODO: need to create API functions to add and delete friends
+
+# TODO: need to create API functions to add, edit, and delete entries of things
+# that you have bought for your friends
+
+# TODO: need to create API functions to change settings
+
 if __name__ == '__main__':
     app.run()