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()
# -*-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):