Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kieut committed Jul 19, 2014
1 parent e8ef6c3 commit 26f2498
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
10 changes: 10 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Flask==0.9
Flask-SQLAlchemy==0.16
Flask-WTF==0.8
Jinja2==2.6
SQLAlchemy==0.7.9
WTForms==1.0.2
Werkzeug==0.8.3
wsgiref==0.1.2
httplib2==0.9
psycopg2==2.5.3
80 changes: 80 additions & 0 deletions webapp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from flask import Flask, request, session, render_template, redirect, flash
import model
import jinja2

app = Flask(__name__)
app.secret_key = 'dress'

@app.route("/")
def index():
"""This is the 'cover' page of the notclothesminded site"""
return render_template("index.html")

@app.route("/signup", methods=["GET"])
def show_signup():
return render_template("signup.html")

@app.route("/signup", methods=["POST"])
def process_sign_up():
email = request.form["email"]
password = request.form["password"]
# print "_____________%r" % d
# 1) create a User object with form data
new_user = model.User(email=email, password=password)
# 2) add object to db
model.db_session.add(new_user)
model.db_session.commit()
return render_template("signup.html")

@app.route("/login", methods=["GET"])
def show_login():
return render_template("login.html")


@app.route("/login", methods=["POST"])
def login():
email = request.form["email"]
password = request.form["password"]
#create a User object with form.data
query = model.db_session.query(model.User)
user = query.filter_by(email=email)

if user == None:
flash("You are not in the database. Please sign up.")
elif user.password != password:
flash("Password incorrect. Unable to log in.")
return render_template("login.html")
else:
#add customer to cookie session, which is a dictionary
session["customer"] = [email, password]
flash("You've successfully logged in.")

#figure out redirect page, homepage?
return redirect("/")

# user = model.db_session.query(model.User).filter_by(email=request.form['email']).filter_by(password=request.form['password']).one()
# print user

return render_template("login.html")


@app.route("/user/<int:id>")
def show_favorites():
"""This page will display the user's saved items, as well as the search facet
panel on the left hand side"""
pass

@app.route("/search")
def search():
#make queries here.
return render_template("search.html")

@app.route("/search_results")
def get_results():
#make queries here.
return render_template("search_results.html")



if __name__ == '__main__':
app.run(debug=True)

0 comments on commit 26f2498

Please sign in to comment.