Example #1
0
from flask import Flask, Response, request, make_response, render_template, redirect, url_for
from flaskext.mysql import MySQL
from random import randint


mysql = MySQL()
app = Flask(__name__)
app.config["MYSQL_DATABASE_USER"] = "msp"
app.config["MYSQL_DATABASE_PASSWORD"] = "monkey2"
app.config["MYSQL_DATABASE_DB"] = "msp"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
mysql.init_app(app)

SESSION_INTERVAL = 15


def auth_user(username, password):
    cur = mysql.connect().cursor()
    cur.execute(
        "SELECT id,ext_id,username,name FROM msp.user where username='%s' and password='%s'" % (username, password)
    )
    if cur.rowcount == 1:
        rv = cur.fetchone()
        return rv[1]
    else:
        return False


def check_session():
    if "msp_session" in request.cookies:
        cur = mysql.connect().cursor()
Example #2
0
from flask import Flask, render_template
from flaskext.mysql import MySQL

app = Flask(__name__)

app.config["MYSQL_DATABASE_HOST"] = "localhost"
app.config["MYSQL_DATABASE_PORT"] = 3306
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "84e5beee-aaf7-11e4-b696-180373e4501b"
app.config["MYSQL_DATABASE_DB"] = 'poppy'
# MYSQL_DATABASE_CHARSET	default is 'utf-8'

mysql = MySQL()
mysql.init_app(app)

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

@app.route('/countries')
def countries():
    cursor = mysql.get_db().cursor()
    cursor.execute("SELECT * FROM countries WHERE userid='1'")
    values = {}
    for userid, USA, India, China, Russia, Germany in cursor:
        return render_template('countries.html', USA=USA, India=India, China=China, Russia=Russia, Germany=Germany)

@app.route('/browsers')
def browsers():
    cursor = mysql.get_db().cursor()
    cursor.execute("SELECT * FROM browsers WHERE userid='1'")
Example #3
0
from flask import Flask, render_template, json, request, redirect, session, jsonify
from flask.ext.mysql import MySQL
from werkzeug import generate_password_hash, check_password_hash

mysql = MySQL()
app = Flask(__name__)
app.secret_key = "why would I tell you my secret key?"

# MySQL configurations
app.config["MYSQL_DATABASE_USER"] = "jay"
app.config["MYSQL_DATABASE_PASSWORD"] = "jay"
app.config["MYSQL_DATABASE_DB"] = "BucketList"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
mysql.init_app(app)

# Default setting
pageLimit = 2


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


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


@app.route("/showAddWish")
def showAddWish():
Example #4
0
# -*- coding:utf-8 -*-
from flask import Flask, render_template, request
from flask_bootstrap3 import Bootstrap
from flaskext.mysql import MySQL
import recom
from models import GoodsTable, SimUserTable

app = Flask(__name__)
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "34092402"
app.config["MYSQL_DATABASE_DB"] = "ad_recom"
app.config["MYSQL_DATABASE_CHARSET"] = "gb2312"
mysql = MySQL(app)


# 路由函数
@app.route("/")
def index():
    user_id = request.args.get("user_id")  # 获取get参数中的user_id
    if user_id != "" and user_id is not None:  # 判空
        cursor = mysql.connect().cursor()

        user_name = recom.find_user_name(cursor, user_id)
        items = recom.simple_recom(cursor, user_id)
        if len(items) > 0:
            goods_table = GoodsTable(items, classes=["goodsTable", "table"])

            usersItem = recom.find_similar_users(cursor, user_id)
            sim_user_table = SimUserTable(usersItem, classes=["simiUserTable", "table"])
            return render_template(
                "index.html",
Example #5
0
from flask import Flask, render_template, request, json
from flask.ext.mysql import MySQL
from werkzeug import generate_password_hash, check_password_hash

app = Flask(__name__)

mysql = MySQL()
# MySQL configurations
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "powerc"
app.config["MYSQL_DATABASE_DB"] = "BucketList"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
mysql.init_app(app)

conn = mysql.connect()
cursor = conn.cursor()


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


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


@app.route("/signUp", methods=["POST"])
def signUp():
    _name = request.form["inputName"]
Example #6
0
from flask import Flask, render_template, request
from flask.ext.mysql import MySQL
import spaza_shop

app = Flask(__name__)

mysql = MySQL()
app.config["DEBUG"] = True

# MySQL configurations
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "MysqlServer123"
app.config["MYSQL_DATABASE_DB"] = "spaza_shop"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
mysql.init_app(app)

connection = mysql.connect()
cursor = connection.cursor()

# url_for('static', filename='main_page.css')
# url_for('static', filename='bootstrap.min.css')
# url_for('static', filename='bootstrap.min.js')
# url_for('static', filename='jquery.js')


@app.route("/popular_category/")
def popular_category():
    sales = spaza_shop.get_sales()
    most_pop_cat = spaza_shop.get_most_pop_cat(sales)

    cursor.execute(
from flask import Flask, render_template, json, request, session, redirect
from flask.ext.mysql import MySQL
from werkzeug import generate_password_hash, check_password_hash

mysql = MySQL()
app = Flask(__name__)
app.config["SESSION_TYPE"] = "memcached"
app.config["SECRET_KEY"] = "super secret key"
# MySQL configurations
# Do not change these values
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "remo161196"
app.config["MYSQL_DATABASE_DB"] = "BucketList"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
mysql.init_app(app)


@app.route("/userHome")
def userHome():
    if session.get("user"):
        return render_template("userHome.html")
    else:
        return render_template("error.html", error="Unauthorized Access")


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


@app.route("/showSignUp")
Example #8
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys

reload(sys)
sys.setdefaultencoding("utf8")

from flask import Flask, request, Response, g, session, url_for, json, jsonify
from flaskext.mysql import MySQL


app = Flask(__name__)
mysql = MySQL()

app.config["MYSQL_DATABASE_USER"] = "kbgiskbg"
app.config["MYSQL_DATABASE_PASSWORD"] = "mysql"
app.config["MYSQL_DATABASE_DB"] = "emotionDB"
app.secret_key = "emotionDB_secret_key"

mysql.init_app(app)


def connect_db():
    return mysql.connect()


def query_db(query, one=False):
    cursor = g.db.cursor()
    cursor.execute(query)

    data = []
# @app.before_request
# def before_request():
#    g.db = setupDb()

# @app.teardown_request
# def teardown_request(exception):
#    db = getattr(g, 'db', None)
#    if db is not None:
#        db.connect().close()

# def setupDb():
mysql = MySQL()

# MySQL configurations
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "nanivallu"
app.config["MYSQL_DATABASE_DB"] = "devathon"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
mysql.init_app(app)
# return mysql


def insertData(name, amount, tags, fromacc, toacc, type, transactiondate):
    # mysql = setupDb()
    conn = mysql.connect()
    cursor = conn.cursor()
    command = "INSERT INTO TRANSACTIONS (NAME, AMOUNT, TAGS, FROMACC, TOACC, TYPE, TRANSACTIONDATE ) VALUES ('{0}', '{1}','{2}','{3}','{4}','{5}','{6}')".format(
        name, amount, tags, fromacc, toacc, type, transactiondate
    )
    try:
        cursor.execute(command)
Example #10
0
from flask import Flask, render_template, json, request, redirect, session, flash, url_for
from flask.ext.mysql import MySQL
from werkzeug import generate_password_hash, check_password_hash
from datetime import datetime
import logging

mysql = MySQL()
app = Flask(__name__)
# app.config.from_envvar('universityapp_settings')
app.secret_key = "secret"

# MySQL configurations
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "password"
app.config["MYSQL_DATABASE_DB"] = "eventwebsite"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
mysql.init_app(app)


@app.route("/")
def main():
    if session.get("user"):
        return redirect("/userhome")
    return render_template("index.html")


# use the def name when calling the route through code


@app.route("/signup")
def signup():
Example #11
0
from flask import Flask, render_template, request, redirect, url_for, jsonify
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from database_setup import Base, Session
from flaskext.mysql import MySQL

mysql = MySQL()
app = Flask(__name__)
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "123456"
app.config["MYSQL_DATABASE_DB"] = "EmpData"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
mysql.init_app(app)


engine = create_engine("mysql://root:123456@localhost/EmpData?charset=utf8&use_unicode=0", pool_recycle=3600)
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
session = DBSession()


@app.route("/")
def hello():
    sans = session.query(Session)
    # return  sans.gender
    return render_template("index.html", items=sans)


@app.route("/Authenticate")
def Authenticate():
# -*-coding:utf-8-*-


from flask import Flask, render_template, redirect
from flaskext.mysql import MySQL

mysql = MySQL()
app = Flask(__name__)
app.config["MYSQL_DATABASE_USER"] = "serverstudy"
app.config["MYSQL_DATABASE_PASSWORD"] = "serverstudy!@#"
app.config["MYSQL_DATABASE_DB"] = "serverstudy"
app.config["MYSQL_DATABASE_HOST"] = "data.khuhacker.com"
app.config["MYSQL_CHARSET"] = "utf-8"
mysql.init_app(app)


@app.route("/userlist/")
def showUser():
    cur = mysql.connect().cursor()
    cur.execute("SELECT * FROM Cs_users")
    data = cur.fetchall()
    cur.close()
    print data
    output = ""
    for user in data:
        output += "NUMBER : %s , NAME : %s , SEX : %s, DATE : %s <br>" % (user[0], user[1], user[2], user[-1])
    return output


@app.route("/adduser/<inumber>/<iname>/<isex>")
def adduser(inumber, iname, isex):