Example #1
0
from flask import Flask, session, request, redirect, g, url_for, abort, render_template, flash
from sqlalchemy.orm import sessionmaker
from sqlalchemy import schema, Column, DateTime, String, Integer, Float, create_engine
from sqlalchemy.orm import backref
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, mapper
from sqlalchemy.sql.functions import now
import pdb

SECRET_KEY = 'rest api'
USERNAME='lxy'
PASSWORD='123'

app = Flask(__name__)
app.config.from_object(__name__)
app.config['TRAP_BAD_REQUEST_ERRORS'] = True

Base = declarative_base()
engine = create_engine("mysql://root:@localhost/mysql", encoding='latin1')


class blogs(Base):
    __tablename__ = 'blogs'
    title = Column(String(60), primary_key=True)
    author = Column(String(40))
    content = Column(String(120))
    created_at = Column(DateTime)
    updated_at = Column(DateTime)

DBsession = sessionmaker(bind=engine)
#DBsession.configure(bind=engine)
Example #2
0
import sqlite3, pprint
from collections import namedtuple
#  from facepy.utils import get_extended_access_token

#Files to include (from here)
from utilities import facebook, DEBUG, SECRET_KEY, TrapErrors, Objects as O, OFFLINE, FACEBOOK_APP_ID, FACEBOOK_APP_SECRET

#Setting up Data
Crawl_Time = 2419200                 # 2419200 = 4 weeks in seconds
Crawl_By_Limit = False               # if False, it will crawl datas by Crawl_Time. if True, it will just crawl last 100 datas of user's timeline..

#Setting up the Application
app = Flask(__name__)
app.debug = DEBUG
app.secret_key = SECRET_KEY
app.config['TRAP_BAD_REQUEST_ERRORS'] = TrapErrors

#Setting path to DB depending on DEBUG setting
if DEBUG == True:
    # dbURL = 'sqlite:////tmp/test.db'
    dbURL = os.environ['DATABASE_URL']
else: 
    dbURL = os.environ['DATABASE_URL']
app.config['SQLALCHEMY_DATABASE_URI'] = dbURL

userCache = {}

db = SQLAlchemy(app)
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    authID = db.Column(db.PickleType, unique=True)