Example #1
0
from functools import wraps
from flask_dance.contrib.twitter import make_twitter_blueprint, twitter
import os
import os.path
import json
from flask_dance.consumer.backend import BaseBackend

from config.keys import Keys

from data.articles import Articles
app = Flask(__name__)

app.config["MYSQL_HOST"] = "localhost"
app.config["MYSQL_USER"] = "root"
app.config["MYSQL_PASSWORD"] = "admin"
app.config["MYSQL_DB"] = "flask"
app.config["MYSQL_CURSORCLASS"] = "DictCursor"

mysql = MySQL(app)

blueprint = make_twitter_blueprint(api_key = Keys.getTwitterKeys()["apiKey"], api_secret = Keys.getTwitterKeys()["apiSecret"])
app.register_blueprint(blueprint, url_prefix="/twitter_login")

# class FileBackend(BaseBackend):
#     def __init__(self, filepath):
#         super(FileBackend, self).__init__()
#         self.filepath = filepath

#     def get(self, blueprint):
#         if not os.path.exists(self.filepath):
#             return None
from flask.ext.mysqldb import MySQL
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash

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"] = "951022"
app.config["MYSQL_DB"] = "my_products"


@app.route("/")
def prodList():
    cur = mysql.connection.cursor()
    cur.execute("""SELECT Id,Name from Products""")
    entries = [dict(Id=row[0], Name=row[1]) for row in cur.fetchall()]

    cur.execute(
        """SELECT SUM(Qty) AS TotalQty , Product_Id, Name from Sales s INNER JOIN Products p ON s.Product_Id = p.Id 					GROUP BY Name"""
    )
    products = [dict(Name=row[2], Qty=row[0]) for row in cur.fetchall()]

    cur.execute("""SELECT Id,Name from Categories""")
    categories = [dict(Id=row[0], Name=row[1]) for row in cur.fetchall()]

    cur.execute(
        """SELECT  Categories.Name, sum(Sales.Qty) AS TotalQty from Sales INNER JOIN Products ON Sales.Product_id = Products.Id INNER JOIN Categories ON Products.Category_id = Categories.Id GROUP BY Categories.Name"""
    )
    cats = [dict(Name=row[0], Qty=row[1]) for row in cur.fetchall()]
Example #3
0
from flask.ext.bcrypt import Bcrypt
from flask.ext.mail import Mail, Message
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash

app = Flask(__name__)
bcrypt = Bcrypt(app)
app.config.from_object(__name__)

app.secret_key = "d4rthV4d3rIsYourF4th3r"

mysql = MySQL(app)
app.config["MYSQL_HOST"] = "localhost"
app.config["MYSQL_PORT"] = 3306
app.config["MYSQL_USER"] = "tarcode"
app.config["MYSQL_PASSWORD"] = "coder123"
app.config["MYSQL_DB"] = "psytrancr"

app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USERNAME"] = "psytrancrapp@gmail.com"
app.config["MAIL_PASSWORD"] = "kanqxjdmrqinukjn"
app.config["MAIL_USE_TLS"] = False
app.config["MAIL_USE_SSL"] = True

mail = Mail(app)
# app.config['DEFAULT_MAIL_SENDER'] =  None

# 	app.config['MYSQL_CHARSET'] = 'utf-8'


@app.route("/", methods=["GET", "POST"])