import os import datetime import re import urllib from unidecode import unidecode from werkzeug.utils import secure_filename from flask import Flask, request, render_template, redirect, Markup, jsonify from flask.ext.mongoengine import mongoengine import models import boto from boto.s3.connection import S3Connection mongoengine.connect('mydata', host=os.environ.get('MONGOLAB_URI'), retryWrites=False) app = Flask(__name__) app.config['CSRF_ENABLED'] = False app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 app.secret_key = os.environ.get('SECRET_KEY') AUTH_STR = os.environ.get('AUTH_STR') ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif', 'pde', 'js']) # ----------------------------------------------------------------- HOME >>> @app.route("/") def index():
import requests # create Flask app app = Flask(__name__) # create our flask app app = Flask(__name__) # create our flask app app.secret_key = os.environ.get( 'SECRET_KEY' ) # put SECRET_KEY variable inside .env file with a random string of alphanumeric characters app.config['CSRF_ENABLED'] = False app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16 megabyte file upload # --------- Database Connection --------- # MongoDB connection to MongoLab's database mongoengine.connect('mydata', host=os.environ.get('MONGOLAB_URI')) app.logger.debug("Connecting to MongoLabs") ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif']) # hardcoded categories for the checkboxes on the form #categories = ['GEAR','TECH','FASHION','BODY','ART','RIDE','PLACE'] # --------- Routes ---------- @app.route("/fsq", methods=['GET', 'POST']) def main(): if request.method == "GET": user_latlng = request.args.get('latlng')
# import requests from flaskext.bcrypt import Bcrypt #custom user library - maps User object to User model from libs.user import * app = Flask(__name__) # create our flask app app.config['CSRF_ENABLED'] = False app.secret_key = os.environ.get('SECRET_KEY') flask_bcrypt = Bcrypt(app) # MONGOLAB_URI=mongodb://localhost:27017/dwdfall2012 mongoengine.connect('mydata', host=os.environ.get('MONGOLAB_URI')) # reference http://packages.python.org/Flask-Login/#configuring-your-application login_manager = LoginManager() login_manager.anonymous_user = Anonymous login_manager.login_view = "login" login_manager.login_message = u"Please log in to access this page." login_manager.refresh_view = "reauth" itemslist = ['shirts', 'suits', 'ties', 'macbooks', 'iPad', 'Adaptors'] # Flask-Login requires a 'user_loader' callback # This method will called with each Flask route request automatically # When this callback runs, it will populate the User object, current_user # reference http://packages.python.org/Flask-Login/#how-it-works @login_manager.user_loader
#___________CONFIG_____________# app = Flask(__name__) #Create the Flask App app.debug = True app.secret_key = os.environ.get('SECRET_KEY') # SECRET_KEY=...... inside .env # app.config['TRAP_BAD_REQUEST_ERRORS'] = True # Flask BCrypt will be used to salt the user password flask_bcrypt = Bcrypt(app) #mongolab connection # uses .env file to get connection string # using a remote db get connection string from heroku config # using a local mongodb put this in .env # MONGOLAB_URI=mongodb://localhost:27017/secondnatureproject mongoengine.connect('userdemo', host=os.environ.get('MONGOLAB_URI')) app.logger.debug("Connecting to MongoLabs") # Login management defined # reference http://packages.python.org/Flask-Login/#configuring-your-application login_manager = LoginManager() login_manager.anonymous_user = Anonymous login_manager.login_view = "login" login_manager.login_message = u"Please log in to access this page." login_manager.refresh_view = "reauth" # Flask-Login requires a 'user_loader' callback # This method will called with each Flask route request automatically # When this callback runs, it will populate the User object, current_user # reference http://packages.python.org/Flask-Login/#how-it-works @login_manager.user_loader
#custom user library - maps User object to User model from libs.user import * app = Flask(__name__) app.debug = True app.secret_key = os.environ.get('SECRET_KEY') # SECRET_KEY=...... inside .env # Flask BCrypt will be used to salt the user password flask_bcrypt = Bcrypt(app) #mongolab connection # uses .env file to get connection string # using a remote db get connection string from heroku config # using a local mongodb put this in .env # MONGOLAB_URI=mongodb://localhost:27017/dwdfall2012 mongoengine.connect('userdemo', host=os.environ.get('MONGOLAB_URI')) # Login management defined # reference http://packages.python.org/Flask-Login/#configuring-your-application login_manager = LoginManager() login_manager.anonymous_user = Anonymous login_manager.login_view = "login" login_manager.login_message = u"Please log in to access this page." login_manager.refresh_view = "reauth" # Flask-Login requires a 'user_loader' callback # This method will called with each Flask route request automatically # When this callback runs, it will populate the User object, current_user # reference http://packages.python.org/Flask-Login/#how-it-works @login_manager.user_loader
#custom user library - maps User object to User model from libs.user import * app = Flask(__name__) app.debug = True # Flask BCrypt will be used to salt the user password flask_bcrypt = Bcrypt(app) UPLOAD_FOLDER = '/home/flask_apps/public_html/apps/myPortfolio/static/uploads/' app.secret_key = os.environ.get('SECRET_KEY') # put SECRET_KEY variable inside .env file with a random string of alphanumeric characters app.config['CSRF_ENABLED'] = False app.config['MAX_CONTENT_LENGTH'] = 4000 * 1024 * 1024 # 16 megabyte file upload # --------- Database Connection --------- # MongoDB connection to MongoLab's database mongoengine.connect('portfolio') # constant vars => app settings ALLOWED_EXTENSIONS = set(['jpg','png','gif']) #items per page (PAGINATION SETTINGS) PER_PAGE = 6 # Login management defined # reference http://packages.python.org/Flask-Login/#configuring-your-application login_manager = LoginManager() login_manager.anonymous_user = Anonymous login_manager.login_view = "login" login_manager.login_message = u"Please log in to access this page." login_manager.refresh_view = "reauth"
) # put SECRET_KEY variable inside .env file with a random string of alphanumeric characters app.config["CSRF_ENABLED"] = False app.config["MAX_CONTENT_LENGTH"] = 16 * 1024 * 1024 # 16 megabyte file upload # Flask BCrypt will be used to salt the user password flask_bcrypt = Bcrypt(app) # --------- Database Connection ---------------------------------------------------- # MongoDB connection to MongoLab's database # uses .env file to get connection string # using a remote db get connection string from heroku config # using a local mongodb put this in .env # MONGOLAB_URI=mongodb://localhost:27017/dwdfall2012 mongoengine.connect("userdemo", host=os.environ.get("MONGOLAB_URI")) app.logger.debug("Connecting to MongoLabs") # Login management defined # reference http://packages.python.org/Flask-Login/#configuring-your-application login_manager = LoginManager() login_manager.anonymous_user = Anonymous login_manager.login_view = "login" login_manager.login_message = u"Please log in to access this page." login_manager.refresh_view = "reauth" # Flask-Login requires a 'user_loader' callback # This method will called with each Flask route request automatically # When this callback runs, it will populate the User object, current_user # reference http://packages.python.org/Flask-Login/#how-it-works @login_manager.user_loader
from flask import Flask, request, render_template, redirect, abort # import all of mongoengine # from mongoengine import * from flask.ext.mongoengine import mongoengine # import data models import models app = Flask(__name__) # create our flask app app.config["CSRF_ENABLED"] = False # --------- Database Connection --------- # MongoDB connection to MongoLab's database mongoengine.connect("mydata", host=os.environ.get("MONGOLAB_URI")) app.logger.debug("Connecting to MongoLabs") # ----------- Lists ----------- # Create the lists that match the name of the ListField in the models.py categories = [ "web", "physical computing", "programming", "video", "music", "installation", "social media",