from flask.ext.mysqldb import MySQL
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash

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"] = "951022"
app.config["MYSQL_DB"] = "my_products"


@app.route("/")
def prodList():
    cur = mysql.connection.cursor()
    cur.execute("""SELECT Id,Name from Products""")
    entries = [dict(Id=row[0], Name=row[1]) for row in cur.fetchall()]

    cur.execute(
        """SELECT SUM(Qty) AS TotalQty , Product_Id, Name from Sales s INNER JOIN Products p ON s.Product_Id = p.Id 					GROUP BY Name"""
    )
    products = [dict(Name=row[2], Qty=row[0]) for row in cur.fetchall()]

    cur.execute("""SELECT Id,Name from Categories""")
    categories = [dict(Id=row[0], Name=row[1]) for row in cur.fetchall()]

    cur.execute(
        """SELECT  Categories.Name, sum(Sales.Qty) AS TotalQty from Sales INNER JOIN Products ON Sales.Product_id = Products.Id INNER JOIN Categories ON Products.Category_id = Categories.Id GROUP BY Categories.Name"""
    )
    cats = [dict(Name=row[0], Qty=row[1]) for row in cur.fetchall()]
Example #2
0
from flask import Flask
from flask.ext.mysqldb import MySQL

app = Flask(__name__)

app.config["MYSQL_USER"] = "myungchan"
app.config["MYSQL_PASSWORD"] = "dbgood"
app.config["MYSQL_DB"] = "myungchan"
app.config["MYSQL_HOST"] = "10.73.38.158"
mysql = MySQL(app)


@app.route("/")
def test():
    cur = mysql.connection.cursor()
    result_header = """
    <body>
        <h1> Next Student List </h1>
        <ul>
    """
    result_tail = """
        </ul>
    </body>
    """

    result_body = ""
    row_header = "<li>"
    row_tail = "</li>"

    cur.execute("USE myungchan")
    cur.execute(
from flask import Flask
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
app.config["MYSQL_HOST"] = "sql3.freemysqlhosting.net"
app.config["MYSQL_USER"] = "yourusername"
app.config["MYSQL_PASSWORD"] = "mypassword"
app.config["MYSQL_DB"] = "yourdatabasename"
mysql = MySQL(app)


@app.route("/")
def index():
    cur = mysql.connection.cursor()
    cur.execute("""SELECT data FROM example WHERE id = 1""")
    rv = cur.fetchall()
    return str(rv)


if __name__ == "__main__":
    app.run(debug=True)
# -*- coding: utf-8 -*-
from flask import Flask, render_template, Response, json, request
from flask.ext.mysqldb import MySQL
import QueryBuilder as qb
import collections

mysql = MySQL()
app = Flask(__name__)
app.config["MYSQL_USER"] = "root"
app.config["MYSQL_PASSWORD"] = "root"
app.config["MYSQL_DB"] = "MiyamoriLab"
app.config["MYSQL_HOST"] = "localhost"
app.config["MYSQL_PORT"] = 3360
app.config["MYSQL_UNIX_SOCKET"] = "/Applications/MAMP/tmp/mysql/mysql.sock"
mysql.init_app(app)

query = qb.QueryBuilder()


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


# http://127.0.0.1:5000/frequencyrank
@app.route("/frequencyrank", methods=["GET"])
def frequencyrank():
    genre = request.args.get("genre", type=str)
    print genre
    cur = mysql.connection.cursor()
    if genre == "all":
Example #5
0
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 #6
0
app.secret_key = "tkssmartkodecodeWorldProdigy232323421@1127@6206birthd#2342)2**("


mail = Mail()
app.config["MAIL_SERVER"] = "smtp.live.com"
app.config["MAIL_PORT"] = 587
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = "uwimonaevals@outlook.com"
app.config["MAIL_PASSWORD"] = "uwimonas;"

mail.init_app(app)

app.config["MYSQL_USER"] = "root"
app.config["MYSQL_PASSWORD"] = "root"
app.config["MYSQL_DB"] = "finalproject"


mysql = MySQL(app)


def allowed_file(filename):
    return "." in filename and filename.rsplit(".", 1)[1] in ALLOWED_EXTENSIONS


@app.route("/photo/", methods=["GET", "POST"])
def upload_file():
    if request.method == "POST":
        file = request.files["file"]
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
Example #7
0
from flask import Flask, request
import json
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
mysql = MySQL(app)
app.secret_key = "superzoman"
app.config["MYSQL_USER"] = "root"
app.config["MYSQL_PASSWORD"] = ""
app.config["MYSQL_DB"] = "test"


def date_handler(obj):
    return obj.isoformat() if hasattr(obj, "isoformat") else obj


@app.after_request
def add_cors_headers(response):
    response.headers.add("Access-Control-Allow-Origin", "*")
    response.headers.add("Access-Control-Allow-Credentials", "true")
    response.headers.add("Access-Control-Allow-Headers", "Content-Type")
    response.headers.add("Access-Control-Allow-Headers", "Authorization")
    response.headers.add("Access-Control-Allow-Methods", "GET")
    response.headers.add("Access-Control-Allow-Methods", "POST")
    response.headers.add("Access-Control-Allow-Methods", "PUT")
    response.headers.add("Access-Control-Allow-Methods", "DELETE")
    return response


@app.route("/table", methods=["GET"])
def table():
#!/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
Example #9
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 #10
0
from flask import Flask
from flask.ext.mysqldb import MySQL
from flask import render_template

app = Flask(__name__)
app.config["MYSQL_USER"] = "root"
app.config["MYSQL_PASSWORD"] = "root"
app.config["MYSQL_DB"] = "home"
mysql = MySQL(app)


@app.route("/")
def users():
    cur = mysql.connection.cursor()
    cur.execute("""SELECT * FROM data""")
    data = cur.fetchall()

    return render_template("index.html", data=data)


if __name__ == "__main__":
    app.run(debug=True, host="0.0.0.0")
Example #11
0
from flask import Flask, render_template

from extensions import mysql
import controllers

# Initialize Flask app with the template folder address
app = Flask(__name__, template_folder="templates")

# Initialize MySQL database connector
app.config["MYSQL_USER"] = "root"
app.config["MYSQL_PASSWORD"] = "root"
app.config["MYSQL_DB"] = "discussion1"
mysql.init_app(app)

# Register the controllers
app.register_blueprint(controllers.album)
app.register_blueprint(controllers.albums)
app.register_blueprint(controllers.pic)
app.register_blueprint(controllers.main)

# Listen on external IPs
# For us, listen to port 3000 so you can just run 'python app.py' to start the server
if __name__ == "__main__":
    # listen on external IPs
    app.run(host="0.0.0.0", port=3000, debug=True)
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)
)


add_skill = "INSERT INTO skillMatrix " "(skill_name, skill_group_name) " "VALUES (%s, %s)"

delete_skill = "DELETE FROM skillMatrix " "WHERE skill_name=%s AND skill_group_name=%s; "
Example #13
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()
Example #14
0
# import threading
# import handler
import datetime
import json
from flask import Flask, jsonify, render_template, request
from flask.ext.mysqldb import MySQL
import MySQLdb
from MySQLdb.cursors import DictCursor
from db_credentials import *

mysql = MySQL()
app = Flask(__name__)
app.config["MYSQL_HOST"] = DB_HOST
app.config["MYSQL_USER"] = DB_USER
app.config["MYSQL_PASSWORD"] = DB_PASS
app.config["MYSQL_DB"] = DB_NAME
mysql.init_app(app)


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


@app.route("/api/sensors")
def all():
    json = []

    cursor = mysql.connection.cursor()
    dict_cursor = mysql.connection.cursor(cursorclass=DictCursor)
Example #15
0
from flask import Flask, request, render_template, make_response, jsonify
import json
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
mysql = MySQL(app)
app.secret_key = "superzoman"
app.config["MYSQL_USER"] = "root"
app.config["MYSQL_PASSWORD"] = ""
app.config["MYSQL_DB"] = "flasktest"


@app.route("/")
def index():
    return render_template("ng-index.html")


@app.route("/db", methods=["GET", "PUT", "POST", "DELETE"])
def db_info():
    db = {}
    table_name = "person"
    db["name"] = app.config["MYSQL_DB"]
    cur = mysql.connection.cursor()

    if request.method == "GET":
        k = cur.execute("""SELECT * FROM """ + table_name)
        data = cur.fetchall()
        desc = cur.description
        result = []
        for i in xrange(k):
            dict = {}
Example #16
0
import controllers
import sys
from getpass import getpass
from extensions import mysql

app = Flask(__name__, template_folder="templates")

app.register_blueprint(controllers.ask)
app.register_blueprint(controllers.explorepage)
app.register_blueprint(controllers.main)
app.register_blueprint(controllers.login)
app.register_blueprint(controllers.userpage)
app.register_blueprint(controllers.addmoreresponse)
app.register_blueprint(controllers.logout)
app.register_blueprint(controllers.about)


app.config["MYSQL_USER"] = "root"
try:
    pw = str(sys.argv[1])  # password supplied as cmd line arg
except:
    pw = getpass("input password: ")
app.config["MYSQL_PASSWORD"] = pw
app.config["MYSQL_DB"] = "bmt"
app.secret_key = '\xfd{H\xe5<\x95\xf9\xe3\x96.5\xd1\x01O<!\xd5\xa2\xa0\x9fR"\xa1\xa8'
mysql.init_app(app)
# comment this out using a WSGI like gunicorn
# if you dont, gunicorn will ignore it anyway
if __name__ == "__main__":
    # listen on external IPs
    app.run(host="localhost", port=5000, debug=True)
Example #17
0
from flask import Flask, render_template
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
mysql = MySQL()
app.config["MYSQL_USER"] = "root"
app.config["MYSQL_DB"] = "EPG_COMMONDB"
app.config["MYSQL_HOST"] = "localhost"
mysql.init_app(app)


@app.route("/")
def total():
    cur = mysql.connection.cursor()
    cur.execute("""select count(*) from epg_source_stats""")
    total = cur.fetchone()
    cur.execute('''select count(*) from epg_source_stats where crawl_status like "Done"''')
    done = cur.fetchone()
    cur.execute('''select count(*) from epg_source_stats where crawl_status= "Hold"''')
    hold = cur.fetchone()
    cur.execute('''select source_name from epg_source_stats where crawl_status= "Done"''')
    done_list = cur.fetchall()
    cur.execute('''select source_name from epg_source_stats where crawl_status= "Hold"''')
    hold_list = cur.fetchall()
    context = {"total": total[0], "done": done[0], "hold": hold[0], "done_list": done_list, "hold_list": hold_list}
    return render_template("layout.html", **context)


if __name__ == "__main__":
    app.run(debug=True)
Example #18
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()
Example #19
0
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,
  port=url.port
Example #20
0
from flask import Flask, render_template, json, request
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
mysql = MySQL()
# MySQL configurations
app.config["MYSQL_USER"] = "root"
app.config["MYSQL_PASSWORD"] = "root"
app.config["MYSQL_DB"] = "votacionesDB"
app.config["MYSQL_HOST"] = "localhost"
mysql.init_app(app)


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


@app.route("/login", methods=["POST"])
def sign_up():
    cursor = mysql.connection.cursor()
    data = json.loads(request.data)
    serie = data.get("serie")
    numero = data.get("numero")
    # # validate the received values
    if serie and numero:
        query = """select votantes.doc_serie, votantes.doc_num from votantes
        where votantes.doc_serie = %s and votantes.doc_num = %s;"""
        cursor.execute(query, (serie, numero))
        return json.dumps(str(cursor.fetchall()))
    else:
Example #21
0
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"])
    except Exception as e:
Example #22
0
from flask import Flask
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
mysql = MySQL()
app.config["MYSQL_USER"] = "*****"
app.config["MYSQL_HOST"] = "kaceapp"
app.config["MYSQL_PASSWORD"] = "*****"
app.config["MYSQL_DB"] = "ORG1"
app.config["MYSQL_PORT"] = 3306
mysql.init_app(app)

# import @ bottom to void circular references
from app import views
Example #23
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"]:
Example #24
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)
Example #25
0
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
from flask.ext.mysqldb import MySQL
from flask import Flask, session, redirect, url_for, escape, request
from datetime import timedelta
from flask.ext.mail import Mail, Message
from forms import ContactForm  # NEW IMPORT LINE


app = Flask(__name__, template_folder="views")
app.secret_key = "super secret key"
mysql = MySQL()
app.config["UPLOAD_FOLDER"] = "uploads/"
app.config["ALLOWED_EXTENSIONS"] = set(["png", "jpg", "jpeg", "gif"])
app.config["MYSQL_USER"] = "root"
app.config["MYSQL_PASSWORD"] = ""
app.config["MYSQL_DB"] = "project"
mysql.init_app(app)

mail = Mail()
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = "umsiwebdesign@gmail.com"
app.config["MAIL_PASSWORD"] = "105sstate"
mail.init_app(app)


@app.before_request
def init_session():
    session.permanent = True
    app.permanent_session_lifetime = timedelta(minutes=5)
Example #26
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 #27
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 #28
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")
Example #29
0
from flask.ext.bcrypt import Bcrypt
from flask.ext.mail import Mail, Message
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"] = "tarcode"
app.config["MYSQL_PASSWORD"] = "coder123"
app.config["MYSQL_DB"] = "psytrancr"

app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USERNAME"] = "psytrancrapp@gmail.com"
app.config["MAIL_PASSWORD"] = "kanqxjdmrqinukjn"
app.config["MAIL_USE_TLS"] = False
app.config["MAIL_USE_SSL"] = True

mail = Mail(app)
# app.config['DEFAULT_MAIL_SENDER'] =  None

# 	app.config['MYSQL_CHARSET'] = 'utf-8'


@app.route("/", methods=["GET", "POST"])