# -*- coding: utf-8 -*-
from flask import Flask,render_template,Response, json,request
from flask.ext.mysqldb import MySQL
import QueryBuilder as qb
import collections

mysql = MySQL()
app = Flask(__name__)
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'root'
app.config['MYSQL_DB'] = 'MiyamoriLab'
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_PORT'] = 3360
app.config['MYSQL_UNIX_SOCKET'] = '/Applications/MAMP/tmp/mysql/mysql.sock'
mysql.init_app(app)

query = qb.QueryBuilder()

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

#http://127.0.0.1:5000/frequencyrank
@app.route('/frequencyrank', methods = ['GET'])
def frequencyrank():
	genre = request.args.get("genre",type=str)
	print genre
	cur = mysql.connection.cursor()
	if genre == "all":
		cur.execute(query.getAllFrequency())
	else:
Example #2
0
File: app.py Project: kamwithak/py
# Developer: Kamran Choudhry

from flask import Flask, session, render_template, flash, redirect, url_for, session, logging, request
from flask_mysqldb import MySQL
from wtforms import Form, StringField, TextAreaField, PasswordField, validators
from passlib.hash import sha256_crypt
from functools import wraps
import os

app = Flask(__name__)

# configure MySQL
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'insert_password'
app.config['MYSQL_DB'] = 'MYFLASKAPP'
app.config['MYSQL_CURSORCLASS'] = 'DictCursor'

# initialize MySQL
mysql = MySQL(app)

# init page
@app.route('/')
def init():
    return render_template('init.html')

# check if the user is currently logged in
def is_logged_in(f):
	@wraps(f)
	def wrap(*args, **kwargs):
		if "logged_in" in session:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from Benevole import Benevole
from flask import Flask
from flask import render_template
from flask import request
from flask_mysqldb import MySQL
from hashlib import md5

app = Flask(__name__)
mysql = MySQL()
app.config['MYSQL_USER'] = 'bhtan'
app.config['MYSQL_PASSWORD'] = 'bacon123'
app.config['MYSQL_DB'] = 'rfid_lanets'
mysql.init_app(app)
authorize = False
username = None
liste_benevole = []

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

@app.route('/login', methods=['GET','POST'])
def login():
    if request.method == 'POST':
        authorization = authentification(request.form['username'], request.form['password'])
        if authorization:
            global authorize
            authorize = authorization
            global username
Example #4
0
from flask import Flask
from flask.ext.mysqldb import MySQL
from flask import request, jsonify, render_template, g, Response
import json


app=Flask(__name__)
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'qwe123'
app.config['MYSQL_DB'] = 'pytest'
mysql = MySQL(app)
app.debug = True

hwConfig = {
                 "modelNo":{
                            "1":'cDAQ9184'
                           },
                 "module":{
                            "AI":'NI9234',
                            "Di":'NI9421',
                            "Do":'NI9472'
                           },
                "channelNo":{
                             "AI1":'Accelerometer',
                             "AI2":'Accelerometer',
                             "AI3":'Accelerometer',
                             "AI4":'Accelerometer'
                            },
                "unit":{
                        "Accelerometer":'m/sec2',
Example #5
0
from flask import Flask, render_template

from extensions import mysql
import controllers

# Initialize Flask app with the template folder address
app = Flask(__name__, template_folder='templates')

# Initialize MySQL database connector
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'root'
app.config['MYSQL_DB'] = 'discussion1'
mysql.init_app(app)

# Register the controllers
app.register_blueprint(controllers.album)
app.register_blueprint(controllers.albums)
app.register_blueprint(controllers.pic)
app.register_blueprint(controllers.main)

# Listen on external IPs
# For us, listen to port 3000 so you can just run 'python app.py' to start the server
if __name__ == '__main__':
    # listen on external IPs
    app.run(host='0.0.0.0', port=3000, debug=True)
Example #6
0
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
from flask.ext.mysqldb import MySQL
from flask import Flask, session, redirect, url_for, escape, request
from datetime import timedelta
from flask.ext.mail import Mail, Message
from forms import ContactForm 					# NEW IMPORT LINE


app = Flask(__name__, template_folder='views')
app.secret_key = "super secret key"
mysql = MySQL()
app.config['UPLOAD_FOLDER'] = 'uploads/'
app.config['ALLOWED_EXTENSIONS'] = set(['png', 'jpg', 'jpeg', 'gif'])
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = ''
app.config['MYSQL_DB'] = 'project'
mysql.init_app(app)

mail = Mail()
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = 'umsiwebdesign@gmail.com'
app.config["MAIL_PASSWORD"] = '105sstate'
mail.init_app(app)

@app.before_request
def init_session():
    session.permanent = True
    app.permanent_session_lifetime = timedelta(minutes=5)
Example #7
0
from flask import Flask, render_template, redirect, jsonify, request
from flask_mysqldb import MySQL
import random

from jinja2 import utils

def strip_tags(html):
    return str(utils.escape(html))


app = Flask(__name__)

app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = ''
app.config['MYSQL_DB'] = 'ideas'
app.config['MYSQL__HOST'] = 'localhost'

mysql = MySQL(app)


currentWeek = 1

def generateString(length):
    return ''.join(random.choice('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') for i in range(length))

def verify_user(cursor, userId, passKey):
    cursor.execute("SELECT * FROM `users` WHERE `longid`=%s AND `passkey`=%s", (userId, passKey))
    if cursor.rowcount > 0:
        success = True
        userNumId = cursor.fetchone()[0]
    else:
Example #8
0
from flask import Flask
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
mysql = MySQL()
app.config['MYSQL_USER'] = '*****'
app.config['MYSQL_HOST'] = 'kaceapp'
app.config['MYSQL_PASSWORD'] = '*****'
app.config['MYSQL_DB'] = 'ORG1'
app.config['MYSQL_PORT'] = 3306
mysql.init_app(app)

# import @ bottom to void circular references
from app import views
Example #9
0
# import threading
# import handler
import datetime
import json
from flask import Flask, jsonify, render_template, request
from flask.ext.mysqldb import MySQL
import MySQLdb
from MySQLdb.cursors import DictCursor
from db_credentials import *

mysql = MySQL()
app = Flask(__name__)
app.config['MYSQL_HOST'] = DB_HOST
app.config['MYSQL_USER'] = DB_USER
app.config['MYSQL_PASSWORD'] = DB_PASS
app.config['MYSQL_DB'] = DB_NAME
mysql.init_app(app)

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

@app.route("/api/sensors")
def all():
    json = []

    cursor = mysql.connection.cursor()
    dict_cursor = mysql.connection.cursor(cursorclass=DictCursor)

    dict_cursor.execute('''SELECT * FROM `t_sensor_info`''')
    si = dict_cursor.fetchall()
Example #10
0
import sqlite3 
from flask import Flask, render_template, flash, redirect, url_for, session, request, logging
#from data import Articles
from flask_mysqldb import MySQL
from wtforms import Form, StringField, TextAreaField, PasswordField, validators, SelectField
from passlib.hash import sha256_crypt
from functools import wraps
from string import maketrans

app = Flask(__name__)

# Config MySQL
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'password'
app.config['MYSQL_DB'] = 'cheatsheet'
app.config['MYSQL_CURSORCLASS'] = 'DictCursor'
# init MYSQL
mysql = MySQL(app)
db_name = 'test.db'

def grouped_bits_to_decimals(pass_a_list_here, presentable=False):
    intab = ','
    outtab = '.'
    transtab = maketrans(intab, outtab)
    ibalik_ako = [] #return this :D
    for octets in pass_a_list_here:
        ibalik_ako.append(int(octets, 2))
    if presentable == False:
        return ibalik_ako
    else:
Example #11
0
import os

from flask import Flask
from flask_mysqldb import MySQL
app = Flask(__name__)

app.config['CONSUMER_KEY'] = os.environ['CONSUMER_KEY']
app.config['CONSUMER_SECRET'] = os.environ['CONSUMER_SECRET']
app.config['MYSQL_USER'] = os.environ.get('MYSQL_USER')
app.config['MYSQL_PASSWORD'] = os.environ.get('MYSQL_PASSWORD')
app.config['MYSQL_DB'] = os.environ.get('MYSQL_DB')
mysql = MySQL(app)

import twitter.views
Example #12
0
from flask import Flask, render_template, redirect, url_for, request, json, session, escape, flash
from passlib.hash import sha256_crypt
import MySQLdb
import requests
import re

application=Flask(__name__)
application.secret_key = 'Valar Morghulis'

application.config['MYSQL_USER'] = 'root'
application.config['MYSQL_PASSWORD'] = '2312onnf'
application.config['MYSQL_DB'] = 'Users'
application.config['MYSQL_HOST'] = 'localhost'
db=MySQLdb.connect(user="root",passwd="2312onnf",db="Users")

c=db.cursor()
citylist2 = []
c.execute('''SELECT cityname FROM City''')
citylist = re.findall(r"\'([A-Za-z]+)\'",str(c.fetchall()))

def weatherdata(citylist):
	weatherlist = []
	for city in citylist:
		r = requests.get("http://api.wunderground.com/api/39f7c55a8cddcff3/conditions/q/India/"+str(city)+".json")
		data = r.json()
		weather = {}
		c=db.cursor()
		c.execute('''SELECT cid FROM City WHERE cityname = %s''',(city,))
		cid= re.findall(r"([0-9]+)",str(c.fetchone()))
		weather['cid'] = cid[0]
		weather['Location'] = data['current_observation']['display_location']['city']
Example #13
0
from flask import Flask
from flask import render_template
from flask import jsonify
from flask.ext.mysqldb import MySQL




app = Flask(__name__)
mysql = MySQL(app)

app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_PORT'] = 3306
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = '2197832'
app.config['MYSQL_DB'] = 'sakonwaba'

@app.route('/')
def main():
	return render_template("index.html")
def sakonwaba():
    cur = mysql.connection.cursor()
    cur.execute("SELECT * FROM products")
    cur.execute("SELECT * FROM products")
    productsResults = [dict(name = row[1])for row in cur.fetchall()]

    return jsonify(productsResults=productsResults)


if __name__ == '__main__':
    app.run(debug=True)
from flask import Flask 
from flask.ext.mysqldb import MySQL 

app = Flask(__name__)
app.config['MYSQL_HOST'] = 'sql3.freemysqlhosting.net'
app.config['MYSQL_USER'] = 'yourusername'
app.config['MYSQL_PASSWORD'] = 'mypassword'
app.config['MYSQL_DB'] = 'yourdatabasename'
mysql = MySQL(app)

@app.route('/')
def index():
	cur = mysql.connection.cursor()
	cur.execute('''SELECT data FROM example WHERE id = 1''')
	rv = cur.fetchall()
	return str(rv)

@app.route('/addone/<string:insert>')
def add(insert):
	cur = mysql.connection.cursor()
	cur.execute('''SELECT MAX(id) FROM example''')
	maxid = cur.fetchone() #(10,)
	cur.execute('''INSERT INTO example (id, data) VALUES (%s, %s)''', (maxid[0] + 1, insert))
	mysql.connection.commit()
	return "Done"

@app.route('/getall')
def getall():
	cur = mysql.connection.cursor()
	cur.execute('''SELECT * FROM example''')
	returnvals = cur.fetchall() #((1, "ID1"), (2, "ID2"),...)
Example #15
0
# -*- coding: UTF-8 -*-
from flask import Flask, render_template, request
from flask.ext.mysqldb import MySQL
import socket

mysql = MySQL()

app = Flask(__name__)

app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = '123456'
app.config['MYSQL_DB'] = 'demoapp'
app.config['MYSQL_HOST'] = 'db.inet'

# app.config['MYSQL_DATABASE_USER'] = 'root'
# app.config['MYSQL_DATABASE_PASSWORD'] = '123456'
# app.config['MYSQL_DATABASE_DB'] = 'demoapp'
# app.config['MYSQL_DATABASE_HOST'] = 'db'

mysql.init_app(app)


@app.route("/")
def main():

    hostname=socket.gethostname()
    ipaddr=socket.gethostbyname(hostname)

    cursor = mysql.connection.cursor()
    cursor.execute('select count(*) as qtde from subscription')
    query = cursor.fetchone()
Example #16
0
from flask import Flask
from flask_mysqldb import MySQL

app = Flask(__name__)
app.config['MYSQL_HOST'] = 'mysql-server'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'password'
app.config['MYSQL_DB'] = 'myapp'
mysql = MySQL(app)

@app.route('/')
def index():
    cur = mysql.connection.cursor()
    cur.execute('''SELECT * FROM location WHERE id = 1''')
    rv = cur.fetchall()
    return str(rv)

if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True, port=80)
Example #17
0
    someone specific.</p>\n'''
home_link = '<p><a href="/">Back</a></p>\n'
footer_text = '</body>\n</html>'

application = Flask(__name__)

#setup mysql connection
mysqlconfig = ConfigParser.RawConfigParser()

mysqlconfig.read('mysql.cfg')

application.config['MYSQL_USER']= mysqlconfig.get('mysql', 'MYSQL_USER')
application.config['MYSQL_PASSWORD']= mysqlconfig.get('mysql', 'MYSQL_PASSWORD')
application.config['MYSQL_HOST']= mysqlconfig.get('mysql', 'MYSQL_HOST')
application.config['MYSQL_PORT']= mysqlconfig.getint('mysql', 'MYSQL_PORT')
application.config['MYSQL_DB']= mysqlconfig.get('mysql', 'MYSQL_DB')
mysql = MySQL(application)

# post a new user to USERS table
@application.route('/post/user/<user_name>', methods=['Post', 'Get'])
@crossdomain(origin='*')
def post_user(user_name):
	conn = mysql.connection
	cursor = conn.cursor()
	query = "INSERT INTO users (name) VALUES ('{}');".format(user_name)
	cursor.execute(query)
	conn.commit()
	cursor.close()
	return "user {} posted to database".format(user_name)

# return all users in USERS table
Example #18
0
from flask.ext.mysqldb import MySQL
from event import Event
import time,datetime
import json
import os
import psycopg2
import urlparse


app = Flask(__name__)
app.debug = True

# MySQL configurations
app.config['MYSQL_USER'] = 'b6d4aa52f18aa3'
app.config['MYSQL_PASSWORD'] = '0580749d'
app.config['MYSQL_DB'] = 'heroku_3d39916556b689d'
app.config['MYSQL_HOST'] = 'us-cdbr-iron-east-03.cleardb.net'
mysql = MySQL(app)


"""
#postgres config
urlparse.uses_netloc.append("postgres")
url = urlparse.urlparse(os.environ["DATABASE_URL"])

conn = psycopg2.connect(
  database=url.path[1:],
  user=url.username,
  password=url.password,
  host=url.hostname,
  port=url.port
Example #19
0
# -*- coding: utf-8 -*-
from flask import Flask, render_template, redirect, url_for
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
app.config['MYSQL_DB'] = 'mybaseball'
app.config['MYSQL_USER'] = 'guest'
app.config['MYSQL_PASSWORD'] = 'aOVG1L2xDC'
app.config['MYSQL_HOST'] = 'localhost'
mysql = MySQL(app)
charset = 'utf-8'
object_type_list = ['league', 'team', 'game', 'player']


def get_table(object_type, id_num, where_string="TRUE"):
    where_string = where_string.encode(charset)
    cur = mysql.connection.cursor()
    cur.execute('USE mybaseball')
    tables = []
    if id_num == 0:
        description = ('No', " ", 'Data')
    elif object_type == object_type_list[0]:

        query = "SELECT league_year, league_name FROM league WHERE league_id = %d" % id_num
        cur.execute(query)
        description = cur.fetchall()

        query = "CALL load_rank_table(%d)" % id_num
        cur.execute(query)
        table = {
            "index": [
Example #20
0
from flask import Flask,request,render_template,make_response,jsonify
import json
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
mysql = MySQL(app)
app.secret_key = 'superzoman'  
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = ''
app.config['MYSQL_DB'] = 'flasktest'

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

@app.route("/db",methods=['GET','PUT','POST','DELETE'])
def db_info():
	db = {}
	table_name = 'person'
	db['name'] = app.config['MYSQL_DB']
	cur= mysql.connection.cursor()
	
	if request.method == 'GET':
		k = cur.execute('''SELECT * FROM '''+table_name)
		data = cur.fetchall()
		desc = cur.description
		result = []
		for i in xrange(k):
			dict = {}
			for j in xrange(len(desc)):
				dict[desc[j][0]] = data[i][j]
Example #21
0
app=Flask(__name__)
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
# app.config['SECRET_KEY']='Thisissupposedtobesecret!'
gmail=Mail(app)
app.config['MAIL_SERVER']='smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = 'shivam.vku@gmail.com'
app.config['MAIL_PASSWORD'] = '7569880950vineet'
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
gmail = Mail(app)

app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = ''
app.config['MYSQL_DB'] = 'flaskappemp'
app.config['MYSQL_CURSORCLASS'] = 'DictCursor'
mysql=MySQL(app)#https://realpython.com/blog/python/the-minimum-viable-test-suite/

@app.route('/')
def home():
	return render_template('home.html')
@app.route('/home111')
def home111():
  return render_template('home1.html')
#---------------------------------nextregi-----------------------
class Councling(Form):
  name = StringField('name', [validators.Length(min =2 , max = 20)])
  date_of_brith = StringField('date_of_brith', [validators.Length(min =2 , max = 20)])
  father_mother_name = StringField('father_mother_name', [validators.Length(min =2 , max = 20)]) 
@app.route('/councling', methods = ['GET', 'POST'])
instructions = '''
    <p><em>Hint</em>: This is a RESTful web service! Append a username
    to the URL (for example: <code>/Thelonious</code>) to say hello to
    someone specific.</p>\n'''
home_link = '<p><a href="/">Back</a></p>\n'
footer_text = '</body>\n</html>'

# EB looks for an 'application' callable by default.
application = Flask(__name__)

#setup mysql connection
application.config['MYSQL_USER']='BDR'
application.config['MYSQL_PASSWORD']='BDRforlife'
application.config['MYSQL_HOST']='bdr.c7uzpeqksgw0.eu-central-1.rds.amazonaws.com'
application.config['MYSQL_PORT']=3306
application.config['MYSQL_DB']='BDR'
mysql = MySQL(application)

# add a rule for the index page.
application.add_url_rule('/', 'index', (lambda: header_text +
    say_hello() + instructions + footer_text))

# add a rule when the page is accessed with a name appended to the site
# URL.
application.add_url_rule('/<username>', 'hello', (lambda username:
    header_text + say_hello(username) + home_link + footer_text))


add_skill = ("INSERT INTO skillMatrix "
    "(skill_name, skill_group_name) "
    "VALUES (%s, %s)")
Example #23
0
from werkzeug import generate_password_hash, check_password_hash, secure_filename

import resizr

application = Flask(__name__)
mysql = MySQL()

# 504 bit session key
application.secret_key  = '?KzNp>j0-7ec;4c9zG]@tjrBy3uCZNeEsDFm*!%buG7A97?#3ANL*97;D?(jpe9'

# Config MySQL
# Don't run as root in production!

application.config['MYSQL_USER'] = 'root'
application.config['MYSQL_PASSWORD'] = 'pythondev'
application.config['MYSQL_DB'] = 'PixelGram'
application.config['MYSQL_HOST'] = 'localhost'
mysql.init_app(application)

# Define uploads folder and allowed file types - Should not be changed for now!
application.config['UPLOAD_FOLDER'] = 'static/uploads'
application.config['MAX_CONTENT_LENGTH'] = 10 * 1024 * 1024
ALLOWED_EXTENSIONS = set(['jpg'])

# Check the uploads folder exists, otherwise create it
print("INFO: Checking if upload folder exists")
if not os.path.exists(application.config['UPLOAD_FOLDER']):
    try:
        print("WARN: Upload folder does not exist, creating it")
        os.makedirs(application.config['UPLOAD_FOLDER'])
    except Exception as e:
Example #24
0
from flask import Flask, render_template, json, request
from flask.ext.mysqldb import MySQL

app = Flask(__name__)
mysql = MySQL()
# MySQL configurations
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'root'
app.config['MYSQL_DB'] = 'votacionesDB'
app.config['MYSQL_HOST'] = 'localhost'
mysql.init_app(app)


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


@app.route('/login', methods=['POST'])
def sign_up():
    cursor = mysql.connection.cursor()
    data = json.loads(request.data)
    serie = data.get('serie')
    numero = data.get('numero')
    # # validate the received values
    if serie and numero:
        query = """select votantes.doc_serie, votantes.doc_num from votantes
        where votantes.doc_serie = %s and votantes.doc_num = %s;"""
        cursor.execute(query, (serie, numero))
        return json.dumps(str(cursor.fetchall()))
    else:
Example #25
0
# -*- coding: utf-8 -*-  
from flask import Flask, request, render_template
from flask.ext.mysqldb import MySQL
from models import *


app = Flask(__name__)
mysql = MySQL(app)
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = ''
app.config['MYSQL_DB'] = 'bigdatasystem'
app.config['MYSQL_HOST'] = '127.0.0.1'

def getMarjorRank(schools, ratio, character):
    

    cur = mysql.connection.cursor()
    
    cur.execute('set names utf8')
    majorLists = []
    for school in schools:

        #求出学校的平均水平
        sqlStr = "select rank from school where schoolId=%d" % (school.schoolId)
        cur.execute(sqlStr)
        schoolResult = cur.fetchall()
        school.rank = schoolResult[0][0]
        sqlStr = "select * from major where schoolId=%d" % (school.schoolId)
        cur.execute(sqlStr)
        results = cur.fetchall()
        #求每个major的评价
Example #26
0
from flask import Flask, render_template, redirect, url_for, request, json, session, escape, flash
from passlib.hash import sha256_crypt
import MySQLdb
import requests
import re

app=Flask(__name__)

app.secret_key = 'Valar Morghulis'

app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = '2312onnf'
app.config['MYSQL_DB'] = 'Users'
app.config['MYSQL_HOST'] = 'localhost'
db=MySQLdb.connect(user="root",passwd="2312onnf",db="Users")

c=db.cursor()
citylist2 = []
c.execute('''SELECT cityname FROM City''')
citylist2 = str(c.fetchall())
citylist = re.findall(r"\'([A-Za-z]+)\'",citylist2)

clist = ["Mumbai","Bangalore"]
#print (clist)
#if 'username' in session:
#		username_session = escape(session['username'])
#		uid_session  = escape(session['uid'])
#		if request.method == 'GET':
#			city = request.args.get('City','')
#		else:
#			city = request.form['City']
Example #27
0
def mysql_test():
	cur = mysql.connection.cursor()
	cur.execute('''SELECT * FROM user''')
	rv = cur.fetchall()
	return str(rv)


@app.errorhandler(404)
def page_not_found(e):
	return "Page not found"


if __name__ == '__main__':
	app.debug = True	
	app.secret_key = '\xc2ogq\xe9\x957*\x12\xabA\nR\x84NY*\x94\xc6;\\\xfa\x13\xf7'

	# logging
	handler = RotatingFileHandler('error.log', maxBytes=10000, backupCount=1)
	handler.setLevel(logging.INFO)
	app.logger.addHandler(handler)

	# mysql
	mysql = MySQL()
	app.config['MYSQL_USER'] = 'root'
	app.config['MYSQL_PASSWORD'] = 'Pwn210577'
	app.config['MYSQL_HOST'] = '127.0.0.1'
	app.config['MYSQL_DB'] = "my_flask_app"
	mysql.init_app(app)

	#run app
	app.run()
Example #28
0
#!flask/bin/python
from flask import Flask, jsonify, render_template

app = Flask(__name__)

from flask.ext.mysqldb import MySQL


app = Flask(__name__)
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'dr4g0000nball'
app.config['MYSQL_DB'] = 'testapp'
app.config['MYSQL_HOST'] = 'localhost'
mysql = MySQL(app)

tasks = [
    {
        'id': 1,
        'title': u'Buy groceries',
        'description': u'Milk, Cheese, Pizza, Fruit, Tylenol', 
        'done': False
    },
    {
        'id': 2,
        'title': u'Learn Python',
        'description': u'Need to find a good Python tutorial on the web', 
        'done': False
    }
]
Example #29
0
from flask import Flask, render_template, flash, redirect, url_for, logging, session, request
from flask_mysqldb import MySQL
from wtforms import Form, StringField, TextAreaField, PasswordField, SelectField, FileField, validators
from passlib.hash import sha256_crypt
from functools import wraps

app = Flask(__name__)
app.secret_key = "hkjlasdfbblasdkjgasdfgqowerqbfaosdfiuy7896"

APP_ROOT = os.path.dirname(os.path.abspath(__file__))

# Config mysql
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'd9*g1v!'
app.config['MYSQL_DB'] = 'gal2018'
app.config['MYSQL_CURSORCLASS'] = 'DictCursor'

# init_mysql
mysql = MySQL(app)

#Check If Logged if logged In
def is_logged_in(f):
    @wraps(f)
    def wrap(*args, **kwargs):
        if 'logged_in' in session:
            return f(*args, **kwargs)
        else:
            flash('Nice try, but you need to be logged in first!', 'danger')
            return redirect(url_for('login'))
    return wrap
Example #30
0
from flask import Flask, session
from datetime import timedelta
import controllers
from flask_images import Images
from project1.models.extensions import mysql, UPLOAD_FOLDER



app = Flask(__name__)
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?Rf'
images = Images(app)


app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'root'
app.config['MYSQL_DB'] = 'album_website'
app.config['MYSQL_HOST'] = 'localhost'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

mysql.init_app(app)

app.register_blueprint(controllers.album)
app.register_blueprint(controllers.albums)
app.register_blueprint(controllers.pic)
app.register_blueprint(controllers.main)
app.register_blueprint(controllers.authentication)

app.permanent_session_lifetime = timedelta(minutes=5)

# comment this out using a WSGI like gunicorn
# if you don't, gunicorn will ignore it anyway