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 datetime import datetime

# from pprint import pprint

# App Configurations
app = Flask(__name__)

# Load config file for DB user info
with open("config.json") as data_file: 
    config = json.load(data_file)

# Set secret key to use the session module
app.secret_key = config["secret_key"]

# MySQL configurations
app.config["MYSQL_DATABASE_USER"] = config["username"]
app.config["MYSQL_DATABASE_PASSWORD"] = config["password"]
app.config["MYSQL_DATABASE_DB"] = "chez_dandangi"
app.config["MYSQL_DATABASE_HOST"] = "localhost"

mysql = MySQL()
mysql.init_app(app)

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

@app.route("/getReservations", methods=['POST'])
def get_reservations():
Example #4
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 = []
# -*-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):