-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b9b375d
Showing
329 changed files
with
89,606 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Virtualenv | ||
venv | ||
env | ||
.Python | ||
include | ||
lib | ||
# Created by https://www.gitignore.io ### Vim ### | ||
[._]*.s[a-w][a-z] | ||
[._]s[a-w][a-z] | ||
*.un~ | ||
Session.vim | ||
.netrwhist *~ | ||
|
||
# Python Packages | ||
*.egg | ||
*.egg-info | ||
bin | ||
build | ||
dist | ||
sdist | ||
eggs | ||
env | ||
parts | ||
var | ||
develop-eggs | ||
.installed.cfg | ||
|
||
# Pip Installer Log | ||
pip-log.txt | ||
|
||
# Unit test / coverage | ||
.coverage | ||
.tox | ||
|
||
# Mac OS X | ||
.DS_Store | ||
|
||
# Generated files | ||
*.[oa] | ||
*.py[co] | ||
*.rbc |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# A simple way to update Flask Heroku's static files. | ||
|
||
# ---------------------- | ||
# Useful variables | ||
# ---------------------- | ||
NORM=\033[0m | ||
BOLD=\033[1m | ||
CHECK=\033[32m✔\033[39m | ||
port=5000 | ||
|
||
|
||
# ---------------------- | ||
# Default build | ||
# ---------------------- | ||
build: | ||
@echo "\n⚡ ${BOLD}This might take a minute${NORM} ⚡\n" | ||
@make clone | ||
@make update | ||
@make js | ||
@rm -rf {bootstrap,update} | ||
@echo "\n⚡ ${BOLD}Successfully updated${NORM} ⚡\n" | ||
|
||
|
||
# ---------------------- | ||
# Clone Bootstrap && Make | ||
# ---------------------- | ||
clone: | ||
@git clone git://github.com/twitter/bootstrap.git | ||
@echo "\n${BOLD}Clone Twitter Bootstrap... ${NORM}${CHECK}\n" | ||
@cd bootstrap; make bootstrap | ||
@cd bootstrap; cp -R less bootstrap/css/less | ||
@cd bootstrap; mv bootstrap ../update | ||
|
||
|
||
# ---------------------- | ||
# External JavaScript | ||
# ---------------------- | ||
js: | ||
@curl http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js > static/js/jquery.js | ||
@echo "\n${BOLD}Grab latest jQuery... ${NORM}${CHECK}\n" | ||
@curl -L http://git.io/less-1.3.0 > static/js/less.js | ||
@echo "\n${BOLD}Grab latest LESS.js... ${NORM}${CHECK}\n" | ||
@curl http://modernizr.com/downloads/modernizr-2.5.3.js > static/js/modernizr.js | ||
@echo "\n${BOLD}Grab latest Modernizr... ${NORM}${CHECK}\n" | ||
|
||
|
||
# ---------------------- | ||
# Update commands | ||
# ---------------------- | ||
update: | ||
@rm -rf static/css/less | ||
@mv update/css/* static/css | ||
@mv update/img/* static/img | ||
@mv update/js/* static/js | ||
@echo "\n${BOLD}Update static files... ${NORM}${CHECK}\n" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
web: gunicorn -w 4 -b "0.0.0.0:$PORT" app:app | ||
init: python create_database.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
Flask App (User app) | ||
================================== | ||
|
||
What is this? | ||
------------- | ||
This application includes a User model that is compatible with [Flask Login](https://flask-login.readthedocs.org). | ||
We've also included a migration script which depends on [Flask Migrate](https://flask-migrate.readthedocs.org) | ||
|
||
This is a | ||
[Flask](http://flask.pocoo.org/) app that can be deployed to [Heroku](https://www.heroku.com/). | ||
|
||
It is based on [flask_heroku](github.com/zachwill/flask_heroku) | ||
|
||
It follows the structure from the [Flask megatutorial](http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world) | ||
|
||
|
||
|
||
Prerequisites | ||
------------- | ||
|
||
It is assumed that you've installed the [heroku toolbelt](http://toolbelt.heroku.com) | ||
|
||
Instructions | ||
------------ | ||
|
||
Clone the repo. | ||
|
||
git clone git@github.com:info3180/demo_user_app.git | ||
cd flask_app | ||
|
||
To clear the git history, remove the .git/ folder | ||
|
||
rm -rf .git/ | ||
|
||
|
||
For your convenience, the project ships with a virtualenv script which means you | ||
can quickly create a virtual environment using the following commands | ||
|
||
python virtualenv.py --no-site-packages venv | ||
source venv/bin/activate | ||
|
||
|
||
Installing Packages | ||
-------------------- | ||
|
||
### pip | ||
|
||
Then, let's get the requirements installed in your isolated test | ||
environment. | ||
|
||
$ pip install -r requirements.txt | ||
|
||
|
||
Running Your Application | ||
------------------------ | ||
|
||
Activate your virtualenv | ||
|
||
source venv/bin/activate | ||
|
||
Now, you can run the application locally. | ||
|
||
python run.py | ||
|
||
|
||
Deploying | ||
--------- | ||
|
||
If you haven't [signed up for Heroku](https://api.heroku.com/signup), go | ||
ahead and do that. You should then be able to [add your SSH key to | ||
Heroku](http://devcenter.heroku.com/articles/quickstart), and also | ||
`heroku login` from the commandline. | ||
|
||
Now, to upload your application, you'll first need to do the | ||
following -- and obviously change `app_name` to the name of your | ||
application: | ||
|
||
heroku create app_name -s cedar | ||
|
||
And, then you can push your application up to Heroku. | ||
|
||
git push heroku master | ||
heroku scale web=1 | ||
|
||
Finally, we can make sure the application is up and running. | ||
|
||
heroku ps | ||
|
||
Now, we can view the application in our web browser. | ||
|
||
heroku open | ||
|
||
And, to deactivate `virtualenv` (once you've finished coding), you | ||
simply run the following command: | ||
|
||
deactivate | ||
|
||
|
||
Next Steps | ||
---------- | ||
|
||
After you've got your application up and running, there a couple next | ||
steps you should consider following. | ||
|
||
1. Create a new `README.md` file. | ||
2. Add your Google Analytics ID to the `base.html` template. | ||
3. Adjust the `author` and `description` `<meta>` tags in the | ||
`base.html` template. | ||
4. Change the `humans.txt` and `favicon.ico` files in the `static` | ||
directory. | ||
5. Change the `apple-touch` icons in the `static` directory. | ||
|
||
|
||
Reactivating the Virtual Environment | ||
------------------------------------ | ||
|
||
If you haven't worked with `virtualenv` before, you'll need to | ||
reactivate the environment everytime you close or reload your terminal. | ||
|
||
$ source venv/bin/activate | ||
|
||
If you don't reactivate the environment, then you'll probably receive a | ||
screen full of errors when trying to run the application locally. | ||
|
||
|
||
Adding Requirements | ||
------------------- | ||
|
||
In the course of creating your application, you may find yourself | ||
installing various Python modules with `pip` -- in which case you'll | ||
need to update the `requirements.txt` file. One way that this can be | ||
done is with `pip freeze`. | ||
|
||
$ pip freeze > requirements.txt | ||
|
||
|
||
Custom Domains | ||
-------------- | ||
|
||
If your account is verified -- and your credit card is on file -- you | ||
can also easily add a custom domain to your application. | ||
|
||
$ heroku addons:add custom_domains | ||
$ heroku domains:add www.mydomainname.com | ||
|
||
You can add a [naked domain | ||
name](http://devcenter.heroku.com/articles/custom-domains), too. | ||
|
||
$ heroku domains:add mydomainname.com | ||
|
||
Lastly, add the following A records to your DNS management tool. | ||
|
||
75.101.163.44 | ||
75.101.145.87 | ||
174.129.212.2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from flask import Flask | ||
from flask.ext.sqlalchemy import SQLAlchemy | ||
import os | ||
|
||
app = Flask(__name__) | ||
app.config['SECRET_KEY'] = 'secret' | ||
app.config['SQLALCHEMY_DATABASE_URI'] = "postgresql://project2:project2@localhost/projectdb" | ||
#app.config['SQLALCHEMY_DATABASE_URI'] = | ||
db = SQLAlchemy(app) | ||
db.create_all() | ||
|
||
from app import views,models |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from flask.ext.wtf import Form | ||
from wtforms import StringField, BooleanField,StringField,PasswordField,SubmitField,TextAreaField,FileField,SelectField | ||
from wtforms.validators import DataRequired,Required | ||
|
||
|
||
class LoginForm(Form): | ||
username = StringField('Username', validators=[Required()]) | ||
password = PasswordField('Password', validators=[Required()]) | ||
submit = SubmitField('Login') | ||
|
||
class SignUpForm(Form): | ||
uploadedfile = FileField('User Image') | ||
username = StringField('Username', validators=[Required()]) | ||
password = PasswordField('Password', validators=[Required()]) | ||
email = StringField('Email', validators=[Required()]) | ||
first_name = StringField('First Name', validators=[Required()]) | ||
last_name = StringField('Last Name', validators=[Required()]) | ||
submit = SubmitField('Sign Up') | ||
|
||
class WishForm(Form): | ||
title = StringField('Title', validators=[Required()]) | ||
description = TextAreaField('Description') | ||
thumbnail = FileField('Custom Image') | ||
url = StringField('Search For Image') | ||
status = SelectField('Status',choices=[('0','Not Received'),('1','Received')]) | ||
submit = SubmitField('Add Wish') | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from . import db | ||
class User(db.Model): | ||
__tablename__ = 'persons' | ||
id = db.Column(db.Integer, primary_key=True) | ||
image = db.Column(db.String(255)) | ||
first_name = db.Column(db.String(80)) | ||
last_name = db.Column(db.String(80)) | ||
username = db.Column(db.String(80), unique=True) | ||
password = db.Column(db.String(255), unique=True) | ||
email = db.Column(db.String(120), unique=True) | ||
addon = db.Column(db.DateTime,nullable=False) | ||
wishes = db.relationship('Wish',backref='user',lazy='dynamic') | ||
|
||
def __init__(self,image,first_name,last_name,username,password,email,addon): | ||
self.image = image | ||
self.first_name = first_name | ||
self.last_name = last_name | ||
self.username = username | ||
self.password = password | ||
self.email = email | ||
self.addon = addon | ||
|
||
def is_authenticated(self): | ||
return True | ||
|
||
def is_active(self): | ||
return True | ||
|
||
def is_anonymous(self): | ||
return False | ||
|
||
def get_id(self): | ||
try: | ||
return unicode(self.id) # python 2 support | ||
except NameError: | ||
return str(self.id) # python 3 support | ||
|
||
def __repr__(self): | ||
return '<User %r>' % (self.username) | ||
|
||
class Wish(db.Model): | ||
__tablename__ = 'wishes' | ||
id = db.Column(db.Integer, primary_key=True) | ||
userid = db.Column(db.Integer, db.ForeignKey('persons.id')) | ||
image = db.Column(db.String(255)) | ||
name = db.Column(db.String(255)) | ||
description = db.Column(db.String(255)) | ||
status = db.Column(db.Boolean) | ||
addon = db.Column(db.DateTime,nullable=False) | ||
|
||
|
||
def __init__(self,userid,image,name,description,status,addon): | ||
self.userid = userid | ||
self.image = image | ||
self.name = name | ||
self.description = description | ||
self.status = status | ||
self.addon = addon | ||
|
||
def get_id(self): | ||
try: | ||
return unicode(self.id) # python 2 support | ||
except NameError: | ||
return str(self.id) # python 3 support | ||
|
||
def __repr__(self): | ||
return '<Wish %r>' % (self.name) | ||
|
||
|
Oops, something went wrong.