Beispiel #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()
Beispiel #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'")
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():
Beispiel #4
0
from flask import Flask, render_template, json, request, redirect, session, jsonify, url_for
from flask.ext.mysql import MySQL
from werkzeug import generate_password_hash, check_password_hash
from werkzeug.wsgi import LimitedStream
import uuid
import os

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

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

# Default setting
pageLimit = 5


class StreamConsumingMiddleware(object):
    def __init__(self, app):
        self.app = app

    def __call__(self, environ, start_response):
        stream = LimitedStream(environ["wsgi.input"], int(environ["CONTENT_LENGTH"] or 0))
        environ["wsgi.input"] = stream
        app_iter = self.app(environ, start_response)
        try:
Beispiel #5
0
from flask import Flask, request, render_template, session, redirect, escape
from flaskext.mysql import MySQL
import json
import sql
import re
import random

app = Flask(__name__)

mysql = MySQL()

app.secret_key = "vprtskvni"

app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "root"
app.config["MYSQL_DATABASE_DB"] = "urlshortener"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
mysql.init_app(app)

my_url = "localhost:5000"

dbHandler = sql.DbHandler(mysql)
dbHandler.create_database()


@app.route("/", methods=["GET"])
def index():
    return render_template("index.html")


@app.route("/add_movie", methods=["GET"])
Beispiel #6
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",
Beispiel #7
0
from flask import Flask, Response, request, render_template, redirect, url_for
from flaskext.mysql import MySQL
import flask.ext.login as flask_login

# for image uploading
from werkzeug import secure_filename
import os, base64

mysql = MySQL()
app = Flask(__name__)
app.secret_key = "super secret string"  # Change this!

# These will need to be changed according to your creditionals
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = ""
app.config["MYSQL_DATABASE_DB"] = "photoshare"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
mysql.init_app(app)

# begin code used for login
login_manager = flask_login.LoginManager()
login_manager.init_app(app)

conn = mysql.connect()
cursor = conn.cursor()
cursor.execute("SELECT email from Users")
users = cursor.fetchall()


def getUserList():
    cursor = conn.cursor()
Beispiel #8
0
# -*- 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 = []
Beispiel #9
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(
Beispiel #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():
# 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)
        conn.commit()
Beispiel #12
0
from flask import Flask, render_template

from controllers.index_view import IndexAPI
from controllers.search_result import SearchAPI
from controllers.rest_view import RestAPI
from controllers.review_view import ReviewAPI

from models import mysql

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

app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_DB"] = "ewl"

mysql.init_app(app)

app.add_url_rule("/", view_func=IndexAPI.as_view("index"))
app.add_url_rule("/search", view_func=SearchAPI.as_view("search_result"))
app.add_url_rule("/restuarant", view_func=RestAPI.as_view("rest_index"))
app.add_url_rule("/restuanrat/review", view_func=ReviewAPI.as_view("review"))


@app.errorhandler(404)
def page_not_found(e):
    return render_template("404.html"), 404


if __name__ == "__main__":
    app.run(debug=True)
Beispiel #13
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():
Beispiel #14
0
import time
from celery import Celery
from flask.ext.mysql import MySQL
from flask import session
from flask import Flask, render_template, json, request,redirect
from werkzeug import generate_password_hash, check_password_hash


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

app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "toor"
app.config["MYSQL_DATABASE_DB"] = "sdb"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
app.config['UPLOAD_FOLDER'] = './static/Uploads'
app.config['CELERY_RESULT_BACKEND'] = "amqp"
app.config['CELERY_BROKER_URL'] = "amqp://guest@localhost//"

mysql.init_app(app)
celery = Celery(app.name,broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)

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

@app.route("/showSignUp")
def showSignUp():
Beispiel #15
0
# 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():

    # read the posted values from the UI
    _date = request.form['search-date']
# -*-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):