Example #1
0
from flask import Flask
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
mysql = MySQL()
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = '941103'
mysql.init_app(app)

@app.route("/helloworld")
def hello():
	cur = mysql.connection.cursor()
	cur.execute("SELECT * FROM helloworld.messages")
	msgs = cur.fetchall()
	return str(msgs)

if __name__=="__main__":
	app.run()
Example #2
0
File: app.py Project: kamwithak/py
# Database Technologies: SHA256 for data encryption and MySQL for server-side storing
# Developer: Kamran Choudhry

from flask import Flask, session, render_template, flash, redirect, url_for, session, logging, request
from flask_mysqldb import MySQL
from wtforms import Form, StringField, TextAreaField, PasswordField, validators
from passlib.hash import sha256_crypt
from functools import wraps
import os

app = Flask(__name__)

# configure MySQL
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'insert_password'
app.config['MYSQL_DB'] = 'MYFLASKAPP'
app.config['MYSQL_CURSORCLASS'] = 'DictCursor'

# initialize MySQL
mysql = MySQL(app)

# init page
@app.route('/')
def init():
    return render_template('init.html')

# check if the user is currently logged in
def is_logged_in(f):
	@wraps(f)
	def wrap(*args, **kwargs):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from Benevole import Benevole
from flask import Flask
from flask import render_template
from flask import request
from flask_mysqldb import MySQL
from hashlib import md5

app = Flask(__name__)
mysql = MySQL()
app.config['MYSQL_USER'] = 'bhtan'
app.config['MYSQL_PASSWORD'] = 'bacon123'
app.config['MYSQL_DB'] = 'rfid_lanets'
mysql.init_app(app)
authorize = False
username = None
liste_benevole = []

@app.route('/')
def index():
    return render_template('login.html')

@app.route('/login', methods=['GET','POST'])
def login():
    if request.method == 'POST':
        authorization = authentification(request.form['username'], request.form['password'])
        if authorization:
            global authorize
            authorize = authorization
            global username
Example #4
0
from flask import Flask
from flask.ext.mysqldb import MySQL
from flask import request, jsonify, render_template, g, Response
import json


app=Flask(__name__)
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'qwe123'
app.config['MYSQL_DB'] = 'pytest'
mysql = MySQL(app)
app.debug = True

hwConfig = {
                 "modelNo":{
                            "1":'cDAQ9184'
                           },
                 "module":{
                            "AI":'NI9234',
                            "Di":'NI9421',
                            "Do":'NI9472'
                           },
                "channelNo":{
                             "AI1":'Accelerometer',
                             "AI2":'Accelerometer',
                             "AI3":'Accelerometer',
                             "AI4":'Accelerometer'
                            },
                "unit":{
                        "Accelerometer":'m/sec2',
Example #5
0
# Example configuration file

# note that you must change username and password for SQL database

import os
from flask import Flask, render_template
from flask.ext.mysqldb import MySQL

import controllers

app = Flask(__name__, template_folder='views')

UPLOAD_FOLDER = './static/pictures'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

mysql = MySQL()
app.config['MYSQL_USER'] ='my_user'
app.config['MYSQL_PASSWORD'] ='my_password'
mysql.init_app(app)

app.secret_key = os.urandom(24).encode('hex')

app.register_blueprint(controllers.main)
Example #6
0
from flask import Flask
from flask.ext.mysqldb import MySQL
app = Flask(__name__)
mysql = MySQL()
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'nike27'
mysql.init_app(app)

@app.route("/helloworld")
def hello():
    cur = mysql.connection.cursor()
    cur.execute('''SELECT * FROM helloworld.messages''')
    msgs = cur.fetchall()
    return str(msgs)

if __name__ == "__main__":
    app.run("0.0.0.0")
instructions = '''
    <p><em>Hint</em>: This is a RESTful web service! Append a username
    to the URL (for example: <code>/Thelonious</code>) to say hello to
    someone specific.</p>\n'''
home_link = '<p><a href="/">Back</a></p>\n'
footer_text = '</body>\n</html>'

application = Flask(__name__)

#setup mysql connection
mysqlconfig = ConfigParser.RawConfigParser()

mysqlconfig.read('mysql.cfg')

application.config['MYSQL_USER']= mysqlconfig.get('mysql', 'MYSQL_USER')
application.config['MYSQL_PASSWORD']= mysqlconfig.get('mysql', 'MYSQL_PASSWORD')
application.config['MYSQL_HOST']= mysqlconfig.get('mysql', 'MYSQL_HOST')
application.config['MYSQL_PORT']= mysqlconfig.getint('mysql', 'MYSQL_PORT')
application.config['MYSQL_DB']= mysqlconfig.get('mysql', 'MYSQL_DB')
mysql = MySQL(application)

# post a new user to USERS table
@application.route('/post/user/<user_name>', methods=['Post', 'Get'])
@crossdomain(origin='*')
def post_user(user_name):
	conn = mysql.connection
	cursor = conn.cursor()
	query = "INSERT INTO users (name) VALUES ('{}');".format(user_name)
	cursor.execute(query)
	conn.commit()
	cursor.close()
Example #8
0
"""
Flask Documentation:     http://flask.pocoo.org/docs/
Jinja2 Documentation:    http://jinja.pocoo.org/2/documentation/
Werkzeug Documentation:  http://werkzeug.pocoo.org/documentation/

This file creates your application.
"""

from flask import Flask
from flask import render_template, request, redirect, url_for
from flask.ext.mysqldb import MySQL
app = Flask(__name__)
mysql = MySQL(app)

app.config['MYSQL_USER'] = "username"
app.config['MYSQL_PASSWORD'] = "password"

@app.route('/test')
def users():
    cur = mysql.connection.cursor()
    cur.execute('''SELECT user, host FROM mysql.user''')
    rv = cur.fetchall()
    return str(rv)


#if __name__ == '__main__':
#    app.run(debug=True)
###
# Routing for your application.
###
Example #9
0
# Out config
import consts
from config import kMySQLSettings

# Utilities
from util import genMarkdownResult


## Web app config
app = Flask(__name__)
app.config['DEBUG'] = consts.DEBUG_APP

# Database connection
app.config['MYSQL_HOST'] = kMySQLSettings['host']
app.config['MYSQL_USER'] = kMySQLSettings['user']
app.config['MYSQL_PASSWORD'] = kMySQLSettings['pwd']
app.config['MYSQL_DB'] = kMySQLSettings['dbname']
app.config['MYSQL_PORT'] = kMySQLSettings['port']
app.config['MYSQL_USE_UNICODE'] = True
app.config['MYSQL_CHARSET'] = 'utf8'

# Cache DB connection factory in global
app.config['DBCONN'] = MySQL(app)

# Pretty print JSON responses only if debugging
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = consts.DEBUG_APP



# Routes in other modules
import permits, neighborhoods, taxlots, crimes, census, demolitions
Example #10
0
 

from flask import Flask
from flask.ext.mysqldb import MySQL
from flask import render_template



app=Flask(__name__)
#SQL configurations
app.config['MYSQL_USER'] = 'candidatosnow'
app.config['MYSQL_PASSWORD'] = 'candidatosnow_hackprma'
app.config['MYSQL_DB'] = 'candidatosnow'
app.config['MYSQL_HOST'] = 'candidatosnow.cncvoluhfnku.us-east-1.rds.amazonaws.com'
app.config['MYSQL_CURSORCLASS'] = 'DictCursor'
mysql=MySQL(app)
# mysql.init_app(app)

@app.route('/')
def landing():


    return render_template('first-window.html')

@app.route('/candidatos/<c_id>')
def secondWindow(c_id):
    return render_template('second-window.html', c_id=c_id)



@app.route('/candidatos/<id>/<p_id>')
Example #11
0
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
rfh = RotatingFileHandler(conf['log_file'],
                          maxBytes=100000,
                          backupCount=2,
                          encoding="UTF-8")
logger.addHandler(rfh)

cs_host = conf['cs_host'] 
cs_port = conf['cs_port'] 
cs_bufsize = conf['cs_bufsize'] 

app = Flask(__name__)
app.config['MYSQL_USER'] = conf['db_user']
app.config['MYSQL_PASSWORD'] = conf['db_pass']
app.config['MYSQL_DB'] = conf['db_db']
app.config['MYSQL_HOST'] = conf['db_host']
db = MySQL(app)
app.config['MAX_CONTENT_LENGTH'] = 9999999
CORS(app)

logger.info("Building vocabularies...")
word_tokenizer = data.Pipeline(vpcnn.vpdataset.clean_str)
char_field = data.Field(lower=True, tokenize=lambda x: list(x))
word_field = data.Field(lower=True, tokenize=word_tokenizer, batch_first=True)
label_field = data.Field(sequential=False, use_vocab=False, preprocessing=int)

label_map_fn = pkg_resources.resource_filename('vpcnn', 'data/labels.txt')
idx_to_lbl = []
lbl_to_idx = {}
Example #12
0
from flask.ext.mysqldb import MySQL
from flask.ext.bcrypt import Bcrypt
from flask import Flask, request, session, g, redirect, url_for, \
     abort, render_template, flash

app = Flask(__name__)
bcrypt = Bcrypt(app)
app.config.from_object(__name__)

app.secret_key = 'd4rthV4d3rIsYourF4th3r'

mysql = MySQL(app)
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_PORT'] = 3306
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'coder123'
app.config['MYSQL_DB'] = 'nelisaFlask'
#	app.config['MYSQL_CHARSET'] = 'utf-8'

@app.route('/')
def show_landing():
    if session:
        return redirect(url_for('show_menu'))
    else:
        return render_template('land.html')

@app.route('/signUp', methods = ['GET', 'POST'])
def signUp():
	if request.method == 'POST':
		if(request.form['password'] == request.form['password2']):
			pw_hash = bcrypt.generate_password_hash(request.form['password'],10)
Example #13
0
from flask import Flask, request
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
mysql = MySQL(app)

app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'thirteeneer'
app.config['MYSQL_DB'] = 'EmpData'
app.config['MYSQL_HOST'] = 'localhost'


@app.route("/")
def hello():
    return "Welcome to Python Flask App!"

@app.route("/Authenticate")
def Authenticate():
    username = request.args.get('UserName')
    print username
    password = request.args.get('Password')
    print password
    cur = mysql.connection.cursor()
    cur.execute("SELECT * from User where Username='" + username + "' and Password='" + password + "'")
    data = cur.fetchone()
    if data is None:
     return "Username or Password is wrong"
    else:
     return "Logged in successfully"

Example #14
0
from flask import Flask,redirect,request#,session
import json
import random
from flask.ext.mysqldb import MySQL
app=Flask('MS_Hack')
mysql=MySQL()

app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'narcos'
app.config['MYSQL_DB'] = 'mshack'
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_PORT']=3306
mysql.init_app(app)
gid=""

@app.route('/',methods=['GET','POST'])
def index():
    cur = mysql.connection.cursor()
    cur.execute("select * from leader;")
    rv = cur.fetchall()
    print str(rv)
    return 'Hello World'


# @app.route('/val')
# def insert():
#     cur=mysql.connection.cursor()
#     cur.execute("insert into member values(%s,%s,%s,%s,%s)",(1,'name','123.4','123.4',0))
#     mysql.connection.commit()
#     return "Done"
Example #15
0
from flask import Flask, render_template, redirect, url_for, request, json, session, escape, flash
from passlib.hash import sha256_crypt
import MySQLdb
import requests
import re

app=Flask(__name__)

app.secret_key = 'Valar Morghulis'

app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = '2312onnf'
app.config['MYSQL_DB'] = 'Users'
app.config['MYSQL_HOST'] = 'localhost'
db=MySQLdb.connect(user="root",passwd="2312onnf",db="Users")

c=db.cursor()
citylist2 = []
c.execute('''SELECT cityname FROM City''')
citylist2 = str(c.fetchall())
citylist = re.findall(r"\'([A-Za-z]+)\'",citylist2)

clist = ["Mumbai","Bangalore"]
#print (clist)
#if 'username' in session:
#		username_session = escape(session['username'])
#		uid_session  = escape(session['uid'])
#		if request.method == 'GET':
#			city = request.args.get('City','')
#		else:
#			city = request.form['City']
Example #16
0
from __future__ import print_function 
from flask import Flask, request, redirect, render_template
from flask_mysqldb import MySQL
import sys

# Create connection with MySQL
mysql = MySQL()

# Create Flask app
app = Flask(__name__)

# Set user, password, database, and host
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'dbswldud'
app.config['MYSQL_DB'] = 'MentalHealth'
app.config['MYSQL_HOST'] = 'localhost'
mysql = MySQL(app)

# Route for getting the result of a query
@app.route('/')
def index():
	cur = mysql.connection.cursor()
	cur.execute('''SELECT * FROM MentalHealth.category_description WHERE category = "sleep"''')
	rv = cur.fetchall()
	return str(rv)

# Route for form with the button 
@app.route('/button', methods=['POST', 'GET'])
def result():
	return render_template('button.html')
Example #17
0
#!flask/bin/python
from flask import Flask, jsonify, render_template

app = Flask(__name__)

from flask.ext.mysqldb import MySQL


app = Flask(__name__)
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'dr4g0000nball'
app.config['MYSQL_DB'] = 'testapp'
app.config['MYSQL_HOST'] = 'localhost'
mysql = MySQL(app)

tasks = [
    {
        'id': 1,
        'title': u'Buy groceries',
        'description': u'Milk, Cheese, Pizza, Fruit, Tylenol', 
        'done': False
    },
    {
        'id': 2,
        'title': u'Learn Python',
        'description': u'Need to find a good Python tutorial on the web', 
        'done': False
    }
]
Example #18
0
from flask import Flask
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
mysql = MySQL()
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'DHGLYjoe521'
mysql.init_app(app)

@app.route("/helloworld")
def hello():
    cur = mysql.connection.cursor()
    cur.execute('SELECT * from helloworld.messages')
    msgs = cur.fetchall()
    return str(msgs)

if __name__ == "__main__":
    app.run()
Example #19
0
# -*- coding: UTF-8 -*-
from flask import Flask, render_template, request
from flask.ext.mysqldb import MySQL
import socket

mysql = MySQL()

app = Flask(__name__)

app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = '123456'
app.config['MYSQL_DB'] = 'demoapp'
app.config['MYSQL_HOST'] = 'db.inet'

# app.config['MYSQL_DATABASE_USER'] = 'root'
# app.config['MYSQL_DATABASE_PASSWORD'] = '123456'
# app.config['MYSQL_DATABASE_DB'] = 'demoapp'
# app.config['MYSQL_DATABASE_HOST'] = 'db'

mysql.init_app(app)


@app.route("/")
def main():

    hostname=socket.gethostname()
    ipaddr=socket.gethostbyname(hostname)

    cursor = mysql.connection.cursor()
    cursor.execute('select count(*) as qtde from subscription')
    query = cursor.fetchone()
Example #20
0
from flask import Flask
from flask import render_template
from flask import jsonify
from flask.ext.mysqldb import MySQL




app = Flask(__name__)
mysql = MySQL(app)

app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_PORT'] = 3306
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = '2197832'
app.config['MYSQL_DB'] = 'sakonwaba'

@app.route('/')
def main():
	return render_template("index.html")
def sakonwaba():
    cur = mysql.connection.cursor()
    cur.execute("SELECT * FROM products")
    cur.execute("SELECT * FROM products")
    productsResults = [dict(name = row[1])for row in cur.fetchall()]

    return jsonify(productsResults=productsResults)


if __name__ == '__main__':
Example #21
0
# -*- coding: utf-8 -*-
from flask import Flask, render_template, redirect, url_for
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
app.config['MYSQL_DB'] = 'mybaseball'
app.config['MYSQL_USER'] = 'guest'
app.config['MYSQL_PASSWORD'] = 'aOVG1L2xDC'
app.config['MYSQL_HOST'] = 'localhost'
mysql = MySQL(app)
charset = 'utf-8'
object_type_list = ['league', 'team', 'game', 'player']


def get_table(object_type, id_num, where_string="TRUE"):
    where_string = where_string.encode(charset)
    cur = mysql.connection.cursor()
    cur.execute('USE mybaseball')
    tables = []
    if id_num == 0:
        description = ('No', " ", 'Data')
    elif object_type == object_type_list[0]:

        query = "SELECT league_year, league_name FROM league WHERE league_id = %d" % id_num
        cur.execute(query)
        description = cur.fetchall()

        query = "CALL load_rank_table(%d)" % id_num
        cur.execute(query)
        table = {
            "index": [
Example #22
0
from flask import Flask, render_template, redirect, url_for, request, json, session, escape, flash
from passlib.hash import sha256_crypt
import MySQLdb
import requests
import re

application=Flask(__name__)
application.secret_key = 'Valar Morghulis'

application.config['MYSQL_USER'] = 'root'
application.config['MYSQL_PASSWORD'] = '2312onnf'
application.config['MYSQL_DB'] = 'Users'
application.config['MYSQL_HOST'] = 'localhost'
db=MySQLdb.connect(user="root",passwd="2312onnf",db="Users")

c=db.cursor()
citylist2 = []
c.execute('''SELECT cityname FROM City''')
citylist = re.findall(r"\'([A-Za-z]+)\'",str(c.fetchall()))

def weatherdata(citylist):
	weatherlist = []
	for city in citylist:
		r = requests.get("http://api.wunderground.com/api/39f7c55a8cddcff3/conditions/q/India/"+str(city)+".json")
		data = r.json()
		weather = {}
		c=db.cursor()
		c.execute('''SELECT cid FROM City WHERE cityname = %s''',(city,))
		cid= re.findall(r"([0-9]+)",str(c.fetchone()))
		weather['cid'] = cid[0]
		weather['Location'] = data['current_observation']['display_location']['city']
Example #23
0
from flask.ext.mysqldb import MySQL
from werkzeug import generate_password_hash, check_password_hash, secure_filename

import resizr

application = Flask(__name__)
mysql = MySQL()

# 504 bit session key
application.secret_key  = '?KzNp>j0-7ec;4c9zG]@tjrBy3uCZNeEsDFm*!%buG7A97?#3ANL*97;D?(jpe9'

# Config MySQL
# Don't run as root in production!

application.config['MYSQL_USER'] = 'root'
application.config['MYSQL_PASSWORD'] = 'pythondev'
application.config['MYSQL_DB'] = 'PixelGram'
application.config['MYSQL_HOST'] = 'localhost'
mysql.init_app(application)

# Define uploads folder and allowed file types - Should not be changed for now!
application.config['UPLOAD_FOLDER'] = 'static/uploads'
application.config['MAX_CONTENT_LENGTH'] = 10 * 1024 * 1024
ALLOWED_EXTENSIONS = set(['jpg'])

# Check the uploads folder exists, otherwise create it
print("INFO: Checking if upload folder exists")
if not os.path.exists(application.config['UPLOAD_FOLDER']):
    try:
        print("WARN: Upload folder does not exist, creating it")
        os.makedirs(application.config['UPLOAD_FOLDER'])
Example #24
0
import os

from flask import Flask
from flask_mysqldb import MySQL
app = Flask(__name__)

app.config['CONSUMER_KEY'] = os.environ['CONSUMER_KEY']
app.config['CONSUMER_SECRET'] = os.environ['CONSUMER_SECRET']
app.config['MYSQL_USER'] = os.environ.get('MYSQL_USER')
app.config['MYSQL_PASSWORD'] = os.environ.get('MYSQL_PASSWORD')
app.config['MYSQL_DB'] = os.environ.get('MYSQL_DB')
mysql = MySQL(app)

import twitter.views
Example #25
0
# -*- coding: utf-8 -*-  
from flask import Flask, request, render_template
from flask.ext.mysqldb import MySQL
from models import *


app = Flask(__name__)
mysql = MySQL(app)
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = ''
app.config['MYSQL_DB'] = 'bigdatasystem'
app.config['MYSQL_HOST'] = '127.0.0.1'

def getMarjorRank(schools, ratio, character):
    

    cur = mysql.connection.cursor()
    
    cur.execute('set names utf8')
    majorLists = []
    for school in schools:

        #求出学校的平均水平
        sqlStr = "select rank from school where schoolId=%d" % (school.schoolId)
        cur.execute(sqlStr)
        schoolResult = cur.fetchall()
        school.rank = schoolResult[0][0]
        sqlStr = "select * from major where schoolId=%d" % (school.schoolId)
        cur.execute(sqlStr)
        results = cur.fetchall()
        #求每个major的评价
Example #26
0
from flask import Flask, render_template, request
from flask.ext.mysqldb import MySQL
from event import Event
import time,datetime
import json
import os
import psycopg2
import urlparse


app = Flask(__name__)
app.debug = True

# MySQL configurations
app.config['MYSQL_USER'] = 'b6d4aa52f18aa3'
app.config['MYSQL_PASSWORD'] = '0580749d'
app.config['MYSQL_DB'] = 'heroku_3d39916556b689d'
app.config['MYSQL_HOST'] = 'us-cdbr-iron-east-03.cleardb.net'
mysql = MySQL(app)


"""
#postgres config
urlparse.uses_netloc.append("postgres")
url = urlparse.urlparse(os.environ["DATABASE_URL"])

conn = psycopg2.connect(
  database=url.path[1:],
  user=url.username,
  password=url.password,
  host=url.hostname,
Example #27
0
def mysql_test():
	cur = mysql.connection.cursor()
	cur.execute('''SELECT * FROM user''')
	rv = cur.fetchall()
	return str(rv)


@app.errorhandler(404)
def page_not_found(e):
	return "Page not found"


if __name__ == '__main__':
	app.debug = True	
	app.secret_key = '\xc2ogq\xe9\x957*\x12\xabA\nR\x84NY*\x94\xc6;\\\xfa\x13\xf7'

	# logging
	handler = RotatingFileHandler('error.log', maxBytes=10000, backupCount=1)
	handler.setLevel(logging.INFO)
	app.logger.addHandler(handler)

	# mysql
	mysql = MySQL()
	app.config['MYSQL_USER'] = 'root'
	app.config['MYSQL_PASSWORD'] = 'Pwn210577'
	app.config['MYSQL_HOST'] = '127.0.0.1'
	app.config['MYSQL_DB'] = "my_flask_app"
	mysql.init_app(app)

	#run app
	app.run()
# some bits of text for the page.
header_text = '''
    <html>\n<head> <title>EB Flask Test</title> </head>\n<body>'''
instructions = '''
    <p><em>Hint</em>: This is a RESTful web service! Append a username
    to the URL (for example: <code>/Thelonious</code>) to say hello to
    someone specific.</p>\n'''
home_link = '<p><a href="/">Back</a></p>\n'
footer_text = '</body>\n</html>'

# EB looks for an 'application' callable by default.
application = Flask(__name__)

#setup mysql connection
application.config['MYSQL_USER']='BDR'
application.config['MYSQL_PASSWORD']='BDRforlife'
application.config['MYSQL_HOST']='bdr.c7uzpeqksgw0.eu-central-1.rds.amazonaws.com'
application.config['MYSQL_PORT']=3306
application.config['MYSQL_DB']='BDR'
mysql = MySQL(application)

# add a rule for the index page.
application.add_url_rule('/', 'index', (lambda: header_text +
    say_hello() + instructions + footer_text))

# add a rule when the page is accessed with a name appended to the site
# URL.
application.add_url_rule('/<username>', 'hello', (lambda username:
    header_text + say_hello(username) + home_link + footer_text))

Example #29
0
import uuid
from flask import Flask, render_template, flash, redirect, url_for, logging, session, request
from flask_mysqldb import MySQL
from wtforms import Form, StringField, TextAreaField, PasswordField, SelectField, FileField, validators
from passlib.hash import sha256_crypt
from functools import wraps

app = Flask(__name__)
app.secret_key = "hkjlasdfbblasdkjgasdfgqowerqbfaosdfiuy7896"

APP_ROOT = os.path.dirname(os.path.abspath(__file__))

# Config mysql
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'd9*g1v!'
app.config['MYSQL_DB'] = 'gal2018'
app.config['MYSQL_CURSORCLASS'] = 'DictCursor'

# init_mysql
mysql = MySQL(app)

#Check If Logged if logged In
def is_logged_in(f):
    @wraps(f)
    def wrap(*args, **kwargs):
        if 'logged_in' in session:
            return f(*args, **kwargs)
        else:
            flash('Nice try, but you need to be logged in first!', 'danger')
            return redirect(url_for('login'))
Example #30
0
from flask import Flask
from flask import render_template
from flask import request
import jinja2
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
mysql = MySQL()
app.config['MYSQL_USER'] = 'it2216'
app.config['MYSQL_HOST'] = 'cs4111.caxmabhvo5cr.us-west-2.rds.amazonaws.com'
app.config['MYSQL_PASSWORD'] = 'kimtorras'
app.config['MYSQL_DB'] = 'cs4111'
mysql.init_app(app)


@app.route('/')
@app.route('/<search>')
def index(search=None):
	cuisines = mysql.connect.cursor()
	cuisines.execute("SELECT DISTINCT cuisine FROM Restaurants;")
	cuisines = cuisines.fetchall()

	zip_codes = mysql.connect.cursor()
	zip_codes.execute("SELECT DISTINCT zip FROM Addresses;")
	zip_codes = zip_codes.fetchall()

	ratings = [2.0, 3.0, 4.0, 5.0]

	restaurant =  request.args.get('restaurant')
	cuisine =  request.args.get('cuisine')
	zipcode = request.args.get('zipcode')