Beispiel #1
0
    def conexion(self):
        mysql = MySQL()
        control = Flask(__name__)

        control.config["MYSQL_DATABASE_USER"] = "wtec"
        control.config["MYSQL_DATABASE_PASSWORD"] = "wtec.s"
        control.config["MYSQL_DATABASE_DB"] = "wtec_webapp"
        control.config["MYSQL_DATABASE_HOST"] = "192.168.227.1"
        mysql.init_app(control)
        return mysql
Beispiel #2
0
from flask import Flask, render_template
from flask.ext.mysql import MySQL

app = Flask(__name__)


mysql = MySQL()

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

import experimentManager.views
Beispiel #3
0
#!/usr/bin/python
from flask import Flask
from flask_restful import Resource, Api
from flask.ext.mysql import MySQL
from random import randint
import json

mysql = MySQL()

# Initialize Flask app
app = Flask(__name__)

# MySQL Config
app.config["MYSQL_DATABASE_USER"] = ""
app.config["MYSQL_DATABASE_PASSWORD"] = ""
app.config["MYSQL_DATABASE_DB"] = ""
app.config["MYSQL_DATABASE_HOST"] = ""

mysql.init_app(app)

api = Api(app)


class Quote(Resource):
    def get(self):
        try:

            # Connect to database
            conn = mysql.connect()
            cursor = conn.cursor()
# all the imports
from contextlib import closing
from flaskext.mysql import MySQL
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash

# configuration
mysql = MySQL()
app = Flask(__name__, static_url_path="/home/sathaye/COEN280/Amazon/static", static_folder="images")
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "sathaye"
app.config["MYSQL_DATABASE_DB"] = "COEN280"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
app.config["MYSQL_DATABASE_PORT"] = 3306
mysql.init_app(app)
app.config.from_object(__name__)

con = mysql.connect()
cursor = con.cursor()
Beispiel #5
0
# create the application object
app = Flask(__name__)
# VARIABLE REQUIRED FOR ADMINISTRATOR MODULE
PAGE_LIMIT = 10


## set up connection to the database

mysql = MySQL()
db = SQLAlchemy(app)
app.config["SQLALCHEMY_DATABASE_URI"] = propertiesparser.getDatabaseSQLAlchemy()

app.secret_key = "F12Zr47j\3yX R~X@H!jmM]Lwf/,?KT"
app.config["MYSQL_DATABASE_USER"] = propertiesparser.getDatabaseUserName()
app.config["MYSQL_DATABASE_PASSWORD"] = propertiesparser.getDatabasePassword()
app.config["MYSQL_DATABASE_DB"] = propertiesparser.getDatabaseName()
app.config["MYSQL_DATABASE_HOST"] = propertiesparser.getDatabaseHost()
mysql.init_app(app)
bootstrap = Bootstrap(app)
moment = Moment(app)
role = ""

## section for the login and registration modules
@app.route("/login")
def login():
    session.pop("username", None)
    return render_template("/login/login.html", title="ENABLE INDIA - LOGIN")


@app.route("/logout")
def Logout():
Beispiel #6
0
thumbRoot = "/mnt/data/xbmc/thumbs/"
resizeThumbs = True
resizedThumbRoot = "/var/www/xbmc/thumbs/"
## DB Config
db_host = "localhost"
db_user = "xbmc"
db_password = "xbmc"
db_name = "MyVideos75"


app = Flask(__name__)

app.config["MYSQL_DATABASE_HOST"] = db_host
app.config["MYSQL_DATABASE_USER"] = db_user
app.config["MYSQL_DATABASE_PASSWORD"] = db_password
app.config["MYSQL_DATABASE_DB"] = db_name
mysql = MySQL()
mysql.init_app(app)


## Routes
@app.route("/")
def home():
    navContext = {"main": "Home", "bread": [["/", "Home"]]}
    mediaCount = {"tveps": 0, "songs": 0}
    movies = getMovies()
    mediaCount["movies"] = len(movies)

    return render_template("home.html", navContext=navContext, mediaCount=mediaCount)

Beispiel #7
0
from flask import Flask, jsonify, render_template, request, json
import MySQLdb

app = Flask(__name__)
app.debug = True
app.config["MYSQL_DATABASE_USER"] = "potts"
app.config["MYSQL_DATABASE_PASSWORD"] = "nicetry"
app.config["MYSQL_DATABASE_DB"] = "potts$Potts"
app.config["MYSQL_DATABASE_HOST"] = "potts.mysql.pythonanywhere-services.com"


class DB:
    conn = None

    def connect(self):
        self.conn = MySQLdb.connect(
            host="potts.mysql.pythonanywhere-services.com", user="potts", passwd="nicetry", db="potts$Potts"
        )

    def commit(self):
        self.conn.commit()

    def query(self, sql):
        try:
            cursor = self.conn.cursor()
            cursor.execute(sql)
        except (AttributeError, MySQLdb.OperationalError):
            self.connect()
            cursor = self.conn.cursor()
            cursor.execute(sql)
        return cursor.fetchall()
Beispiel #8
0
import urllib
from Quiz import Quiz

# noinspection PyUnresolvedReferences
from flask.ext.mysql import MySQL
from flask import jsonify
from werkzeug import generate_password_hash, check_password_hash

mysql = MySQL()
app = Flask(__name__)


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


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


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


@app.route("/getQuestions", methods=["GET"])
Beispiel #9
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 #10
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 #11
0
from flask import Flask, render_template, redirect, request
from flask.ext.mysql import MySQL
import datetime

app = Flask(__name__)

mysql = MySQL()
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_DB"] = "persons_db"
mysql.init_app(app)


@app.route("/")
def main():
    conn = mysql.connect()
    cursor = conn.cursor()

    cursor.execute("SELECT * FROM persons")
    persons = cursor.fetchall()

    conn.commit()
    cursor.close()
    conn.close()
    return render_template("index.html", persons=persons)


@app.route("/submit", methods=["POST"])
def submit():
    conn = mysql.connect()
    cursor = conn.cursor()
Beispiel #12
0
mysql = MySQL()

app.config["MYSQL_DATABASE_HOST"] = (
    os.environ["MYSQL_DATABASE_HOST"] if "MYSQL_DATABASE_HOST" in os.environ else config.MYSQL_DATABASE_HOST
)
app.config["MYSQL_DATABASE_PORT"] = (
    os.environ["MYSQL_DATABASE_PORT"] if "MYSQL_DATABASE_PORT" in os.environ else config.MYSQL_DATABASE_PORT
)
app.config["MYSQL_DATABASE_USER"] = (
    os.environ["MYSQL_DATABASE_USER"] if "MYSQL_DATABASE_USER" in os.environ else config.MYSQL_DATABASE_USER
)
app.config["MYSQL_DATABASE_PASSWORD"] = (
    os.environ["MYSQL_DATABASE_PASSWORD"] if "MYSQL_DATABASE_PASSWORD" in os.environ else config.MYSQL_DATABASE_PASSWORD
)
app.config["MYSQL_DATABASE_DB"] = (
    os.environ["MYSQL_DATABASE_DB"] if "MYSQL_DATABASE_DB" in os.environ else config.MYSQL_DATABASE_DB
)

mysql.init_app(app)

if "SECRET_KEY" in os.environ:
    app.config["SECRET_KEY"] = os.environ["SECRET_KEY"]
else:
    app.config["SECRET_KEY"] = os.urandom(24)


def connect_db():
    return mysql.connect()


def check_auth():
"""'
Flask-MySQL
https://flask-mysql.readthedocs.org/en/latest/  
http://codehandbook.org/python-web-application-development-using-flask-and-mysql/  
"""


from flask import Flask
from flaskext.mysql import MySQL

mysql = MySQL()
app = Flask(__name__)
app.config["MYSQL_DATABASE_HOST"] = "localhost"
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "admin"
app.config["MYSQL_DATABASE_DB"] = "tophot"

mysql.init_app(app)


@app.route("/")
def hello():
    conn = mysql.connect()
    cursor = conn.cursor()
    cursor.execute("SET NAMES utf8mb4;")  # or utf8 or any other charset you want to handle

    cursor.execute("SET CHARACTER SET utf8mb4;")  # same as above

    cursor.execute("SET character_set_connection=utf8mb4;")  # same as above
    a = cursor.execute("SELECT * FROM question")  # 返回记录条数
    print(a)
Beispiel #14
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 #15
0
from flask import Flask, render_template, request, url_for, flash, session, redirect  # NEW IMPORT -- request
from flask.ext.wtf import Form
from wtforms import TextField, TextAreaField, SubmitField, PasswordField
from forms import ContactForm, GeturlForm, ChangeForm  # NEW IMPORT LINE
from flaskext.mysql import MySQL
from flask.ext.login import login_user, login_required, logout_user, LoginManager
from functools import wraps

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

login_manager = LoginManager()
login_manager.init_app(app)
# login_manager.login_view = "user.login"

UPLOAD_FOLDER = "/Home/Github/Teamproject/static"
ALLOWED_EXTENSIONS = set(["txt", "pdf", "png", "jpg", "jpeg", "gif"])
app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER

# decorator that links...
@app.route("/")  # This is the main URL
def default():
    return render_template("index.html", name="index", title="HOME PAGE")  # The argument should be in templates folder

Beispiel #16
0
from flask import Flask, request, send_file
from flaskext.mysql import MySQL
import json

UPLOAD_FOLDER = "/Users/choiinho/Dropbox/SWMaestro/Andorid/flask-py/image"

app = Flask(__name__)
mysql = MySQL()

app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "1234"
app.config["MYSQL_DATABASE_DB"] = "android"

mysql.init_app(app)


@app.route("/")
def helloWorld():
    return "Hello World"


@app.route("/loadData", methods=["GET", "POST"])
def loadData():
    cursor = mysql.connect().cursor()
    cursor.execute("select * from next_android_nextagram")

    result = []
    columns = tuple([d[0] for d in cursor.description])
    for row in cursor:
        result.append(dict(zip(columns, row)))
    print (result)
Beispiel #17
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 #18
0
from flask import Flask, render_template, json, request, jsonify, session, escape
from flask.ext.mysql import MySQL

app = Flask(__name__)
app.secret_key = "F12Zr47j\3yX R~X@H!jmM]Lwf/,?KT"

mysql = MySQL()

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


@app.route("/")
def main():
    session.pop("playername", None)
    session.pop("point", None)
    return render_template("welcome.html")


@app.route("/signIn", methods=["POST"])
def signIn():
    _name = request.form["txtName"]
    _password = request.form["txtPassword"]

    conn = mysql.connect()
    cursor = conn.cursor()
Beispiel #19
0
from flask import Flask, render_template, json, request, send_from_directory
import json
import mysql.connector
from werkzeug import generate_password_hash, check_password_hash
import html.parser
import vincent
import csv
import os


app = Flask(__name__)

# MySQL configurations
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = ""
app.config["MYSQL_DATABASE_DB"] = "info257"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
user = "root"
password = ""
port = "localhost"
db = "info257"


def create_table(material, title_list=None, ns=6):
    table = '<div class="datagrid"><table border=1 frame=void rules="rows">                           \
            <thead></thead>                                         \
            <tfoot><tr></tr></tfoot><tbody>'
    i = 0
    for item in material:
        table += "<tr>"
        if i == 0 and title_list != None:
Beispiel #20
0
from config import MYSQL_INFO

from sparkquery import sparkQuery
from mysqlquery import mysqlQuery

import MySQLdb as mysql

import threading
import json

# init flask app
app = Flask(__name__)
app.config.from_object(__name__)

app.config["MYSQL_DATABASE_HOST"] = MYSQL_INFO["host"]
app.config["MYSQL_DATABASE_DB"] = MYSQL_INFO["db"]
app.config["MYSQL_DATABASE_USER"] = MYSQL_INFO["user"]
app.config["MYSQL_DATABASE_PASSWORD"] = MYSQL_INFO["passwd"]


def general_query(source="hive", timestart=0, timeend=0, tp=0, pt1=(0, 0), pt2=(0, 0), mmsi=[0], output="csv"):
    """general query function
		Args:
			source: 	data source, include 'hive', 'mysql', 'oracle'
			timestart:	start time of query range
			timeend:	end time of query range
			type:		space query type, 
						0: pt1 is upper left (lo,la) coordinate, pt2 is (vertical, horizontal) length
						1: pt1 is upper left (lo,la) coordinate, pt2 is lower right (lo,la) coordinate
						2: pt1 is the centor of the circle and pt2 is (R,0) where R is the redius
			pt1:		(lo,la) point
Beispiel #21
0
from flask import Flask, jsonify
from flaskext.mysql import MySQL
from user import user_api
from forum import forum_api
from threaad import thread_api
from post import post_api

mysql = MySQL()

app = Flask(__name__)

app.config["MYSQL_DATABASE_USER"] = "dev"
app.config["MYSQL_DATABASE_PASSWORD"] = "12345678"
app.config["MYSQL_DATABASE_DB"] = "db_project"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
app.config["JSONIFY_PRETTYPRINT_REGULAR"] = False

app.register_blueprint(user_api, url_prefix="/db/api/user/")
app.register_blueprint(forum_api, url_prefix="/db/api/forum/")
app.register_blueprint(thread_api, url_prefix="/db/api/thread/")
app.register_blueprint(post_api, url_prefix="/db/api/post/")

mysql.init_app(app)


@app.route("/", methods=["GET"])
def hello():
    conn = mysql.get_db()
    cursor = conn.cursor()
    cursor.execute("SELECT @@FOREIGN_KEY_CHECKS")
    return jsonify(code=0, response=cursor.fetchall()[0][0])
Beispiel #22
0
from werkzeug.security import generate_password_hash, check_password_hash
from datetime import datetime, date, time, timedelta
import config


app = Flask(__name__)
app.config["DEBUG"] = True
app.config["PROPAGATE_EXCEPTIONS"] = True


mysql = MySQL()

# MySQL configurations
app.config["MYSQL_DATABASE_USER"] = config.DB_USER
app.config["MYSQL_DATABASE_PASSWORD"] = config.DB_PW
app.config["MYSQL_DATABASE_DB"] = config.DB_SCHEMA
app.config["MYSQL_DATABASE_HOST"] = config.DB_HOST
mysql.init_app(app)

app.secret_key = "I miss the comfort in being sad."


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


@app.route("/signUp", methods=["GET"])
Beispiel #23
0
import datetime

CLIENT_ID = "456555048105-49j7n97kvjuluk4f0b3598m70sk0e293"
SCOPE = "https://www.googleapis.com/auth/calendar"
CLIENT_SECRET_FILE = "client_secret.json"
APPLICATION_NAME = "SmartShower"

app = Flask(__name__)
mysql = MySQL()

app.secret_key = "super secret key"
app.config["SESSION_TYPE"] = "filesystem"

app.config["MYSQL_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = "root"
app.config["MYSQL_DATABASE_DB"] = "SmartShowerDB"
app.config["MYSQL_DATABASE_HOST"] = "localhost"

mysql.init_app(app)

##################################################################


def get_long(new_start, new_end, scheduled_start, scheduled_end):
    if scheduled_end - new_start > new_end - scheduled_start:
        return 0
    else:
        return 1


def single_double(new_start, new_end, first_start, first_end):
Beispiel #24
0
from flask import Flask
from flask_restful import Resource, Api
from flask_restful import reqparse
from flask.ext.mysql import MySQL
import os


mysql = MySQL()
app = Flask(__name__)

# MySQL configurations
app.config["MYSQL_DATABASE_USER"] = os.environ["MYSQL_USER"]
app.config["MYSQL_DATABASE_PASSWORD"] = os.environ["MYSQL_PASSWORD"]
app.config["MYSQL_DATABASE_DB"] = "ItemListDb"
app.config["MYSQL_DATABASE_HOST"] = os.environ["MYSQL_URL"]
app.config["MYSQL_DATABASE_PORT"] = 3306


mysql.init_app(app)

api = Api(app)


class AuthenticateUser(Resource):
    def post(self):
        try:
            # Parse the arguments

            parser = reqparse.RequestParser()
            parser.add_argument("email", type=str, help="Email address for Authentication")
            parser.add_argument("password", type=str, help="Password for Authentication")
Beispiel #25
0
from datetime import datetime, timedelta
from hashlib import sha1
import time, os, json, base64, hmac, urllib


global app, mysql, mail, baseS3Url

app = Flask(__name__)

mysql = MySQL()
baseS3Url = "https://filshack.s3.amazonaws.com/"

app.config["MYSQL_DATABASE_USER"] = "b0c31b0e5f6108"
app.config["MYSQL_DATABASE_PASSWORD"] = "a28c9ca5243937f"
app.config["MYSQL_DATABASE_HOST"] = "us-cdbr-iron-east-03.cleardb.net"
app.config["MYSQL_DATABASE_DB"] = "heroku_d4e136b9b4dc6f5"
app.config["AWS_S3_BUCKET"] = "filmshack"
app.config["AWS_ACCESS_KEY_ID"] = "AKIAJMYLTY2I4EHYNUVA"
app.config["AWS_SECRET_ACCESS_KEY"] = "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"
app.config["SECRET_KEY"] = "SET T0 4NY SECRET KEY L1KE RAND0M H4SH"

"""
url = urlparse.urlparse(os.environ['DATABASE_URL'])
app.config['MYSQL_DATABASE_USER'] = url.username
app.config['MYSQL_DATABASE_PASSWORD'] = url.password
app.config['MYSQL_DATABASE_HOST'] = url.hostname
app.config['MYSQL_DATABASE_DB'] = "heroku_d4e136b9b4dc6f5"
app.config['SECRET_KEY'] = 'SET T0 4NY SECRET KEY L1KE RAND0M H4SH'
"""

app.config.update(
Beispiel #26
0
            cursor.callproc("sp_tasks_sp", (u_id))
            data = cursor.fetchall()
            print "Aditya"
            print data
            return "Aditya"
        else:
            print "NOT ADITYA"
            return "INVALID USER!"
    except Exception as e:
        return json.dumps({"error": str(e)})
    finally:
        cursor.close()
        conn.close()


if __name__ == "__main__":
    mysql = MySQL()

    mysql_config_file = "config.json"

    with open(mysql_config_file) as data_file:
        data = json.load(data_file)

        # MySQL configurations
        app.config["MYSQL_DATABASE_HOST"] = data["hostname"]
        app.config["MYSQL_DATABASE_USER"] = data["username"]
        app.config["MYSQL_DATABASE_PASSWORD"] = data["password"]
        app.config["MYSQL_DATABASE_DB"] = data["database"]

    mysql.init_app(app)
    app.run(debug=True)
Beispiel #27
0

""" @app.route("/profile/<username>")
def show_user_profile(username):
    return "User: " + str(username)

@app.route("/post/<int:post_id>")
def show_user_post(post_id):
    return "Post: " + str(post_id)

@app.route("/")
def show_url_for():
    return url_for('show_user_profile', username = 'arif') """

if __name__ == "__main__":
    app.secret_key = "SuperSecretKey"
    app.debug = True

    # mysql
    mysql = MySQL()
    app.config["MYSQL_DATABASE_USER"] = "root"
    app.config["MYSQL_DATABASE_PASSWORD"] = "test"
    app.config["MYSQL_DATABASE_DB"] = "my_flask_app"
    app.config["MYSQL_DATABASE_HOST"] = "mqsql"
    mysql.init_app(app)

    # logging
    handler = RotatingFileHandler("error.log", maxBytes=10000, backupCount=1)
    handler.setLevel(logging.INFO)
    app.logger.addHandler(handler)
    app.run(host="0.0.0.0")
Beispiel #28
0
#!/usr/bin/python
from flask import Flask, render_template, request, flash, Session, url_for, redirect
from flaskext.mysql import MySQL
from flask.ext.login import LoginManager, UserMixin, login_required, login_user, logout_user, current_user
import os

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

app.config["SECRET_KEY"] = "secret"
app.config["IMAGE_FOLDER"] = "static/images/recettes"

login_manager = LoginManager()
login_manager.init_app(app)


class User(UserMixin):
    """docstring for User"""

    def __init__(self, login, id, active=True):
        self.login = login
        self.id = id
        self.active = active

        cursor = mysql.connect().cursor()
        query = "SELECT * FROM Eleve WHERE Id_eleve = " + str(id)
Beispiel #29
0
from flask.ext.triangle import Triangle
from werkzeug import generate_password_hash, check_password_hash
from werkzeug.wsgi import LimitedStream
import collections
import uuid
import os

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

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

# Default setting
pageLimit = 3


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)
Beispiel #30
0
from flask import Flask
from flaskext.mysql import MySQL
from flask.ext.sqlalchemy import SQLAlchemy
import sqlalchemy
import os

app = Flask(__name__)
mysql = MySQL()
app.config["MYSQL_DATABASE_USER"] = "root"
app.config["MYSQL_DATABASE_PASSWORD"] = ""
app.config["MYSQL_DATABASE_DB"] = "Mobiles"
app.config["MYSQL_DATABASE_HOST"] = "localhost"
mysql.init_app(app)
app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://root:@localhost/Mobiles"
app.config["SECRET_KEY"] = "madthing"
db = SQLAlchemy(app)


from app import views, models

if __name__ == "__main__":
    app.run()