-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
v1.0
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from app import app | ||
from app.views import socketio | ||
|
||
|
||
if __name__ == '__main__': | ||
app.run(debug=True) | ||
socketio.run(app) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## This folder _contains the application files_ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
from flask import Flask | ||
from app.config import Config | ||
from flask_mongoalchemy import MongoAlchemy | ||
|
||
|
||
app = Flask(__name__) | ||
app.config.from_object(Config) | ||
db = MongoAlchemy(app) | ||
|
||
|
||
from app import models, views |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import os | ||
|
||
# path of this file | ||
basedir = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
|
||
class Config(object): | ||
|
||
SECRET_KEY = os.environ.get('SECRET_KEY') or 'secret' | ||
# sets MongoDB database | ||
MONGOALCHEMY_DATABASE = 'flask-simple-form' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from flask_wtf import FlaskForm | ||
from wtforms import StringField, SubmitField, PasswordField | ||
from wtforms.validators import DataRequired, Email, ValidationError | ||
from app.models import Users as User | ||
|
||
|
||
class UserForm(FlaskForm): | ||
first_name = StringField('First name:', validators=[DataRequired()]) | ||
last_name = StringField('Last:', validators=[DataRequired()]) | ||
email = StringField('Email:', validators=[DataRequired(), Email()]) | ||
password = PasswordField('Password:', validators=[DataRequired()]) | ||
company = StringField('Company: ') | ||
city = StringField('City: ') | ||
state = StringField('State :') | ||
submit = SubmitField("submit") | ||
|
||
|
||
def validate_email(self, email): | ||
user = User.query.filter(User.email == email.data).first() | ||
if user is not None: | ||
print('This email is taken !!') | ||
raise ValidationError('This email is taken !!') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from app import db | ||
from werkzeug.security import generate_password_hash | ||
from werkzeug.security import check_password_hash | ||
|
||
|
||
class Users(db.Document): | ||
first_name = db.StringField(max_length=64) | ||
last_name = db.StringField(max_length=64) | ||
email = db.StringField(max_length=64) | ||
password = db.StringField(max_length=64) | ||
password_hash = db.StringField(max_length=128, required=False) | ||
company = db.StringField(max_length=128, required=False) | ||
city = db.StringField(max_length=128, required=False) | ||
state = db.StringField(required=False) | ||
|
||
# get user full_name | ||
def full_name(self): | ||
return str(self.first_name + " " + self.last_name) | ||
|
||
# set_password | ||
def set_password(self, password): | ||
self.password_hash = generate_password_hash(password) | ||
|
||
# check_password | ||
def check_password(self, password): | ||
return check_password_hash(self.password_hash, password) | ||
|
||
# for User object representation | ||
def __repr__(self): | ||
return "< User : {} {}>".format(self.first_name, self.last_name) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## This folder contains __Stylesheets JavaScript_ files |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,7 @@ h2 { | |
} | ||
|
||
|
||
|
||
table { | ||
table-layout: fixed; | ||
width: 800px; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,10 @@ h1 { | |
} | ||
|
||
|
||
#red { | ||
color: #d10046; | ||
} | ||
|
||
table { | ||
table-layout: fixed; | ||
width: 800px; | ||
|