# setup flask
from flask import Flask, render_template, request, redirect, url_for, jsonify, flash, g, session
app = Flask(__name__)

# setup client id and secret of github application for oauth 
from flask.ext.github import GitHub

# config application
app.config['GITHUB_CLIENT_ID'] = None
app.config['GITHUB_CLIENT_SECRET'] = None
app_secret = None
github_callback_url = None
github = GitHub(app)

# setup sqlalchemy
from sqlalchemy import create_engine, desc
from sqlalchemy.orm import sessionmaker,scoped_session
from database_setup import Base, Category, Item, User
engine = create_engine('sqlite:///catalog.db')

Base.metadata.bind = engine

db_session = scoped_session(sessionmaker(autocommit=False,
	autoflush=False,
	bind=engine))

Base.query = db_session.query_property()

# route
@app.route('/')
"""show whole catalog with latest items"""
# setup flask
from flask import Flask, render_template, request, redirect, url_for, jsonify, flash, g, session
from flask.ext.seasurf import SeaSurf
app = Flask(__name__)
csrf = SeaSurf(app)
# setup ssl if needed
"""import ssl
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.load_cert_chain('/etc/ssl/private/server.pem')"""

# setup client id and secret of github application for oauth 
from flask.ext.github import GitHub

# config application
app.config['GITHUB_CLIENT_ID'] = 'XXX'
app.config['GITHUB_CLIENT_SECRET'] = 'YYY'
app_secret = 'ZZZ'
github_callback_url = "https://dev.danielburkard.de/github-callback"
github = GitHub(app)

# setup sqlalchemy
from sqlalchemy import create_engine, desc
from sqlalchemy.orm import sessionmaker,scoped_session
from database_setup import Base, Category, Item, User
engine = create_engine('sqlite:///catalog.db')

Base.metadata.bind = engine

# http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html#sqlalchemy.orm.scoping.scoped_session
db_session = scoped_session(sessionmaker(autocommit=False,
	autoflush=False,