Example #1
0
def app():
    app = create_app(environment='test', storage='postgres')
    with app.app_context():
        db.create_all()
        Migrate(app, db)

    yield app

    with app.app_context():
        db.session.remove()
        db.drop_all()
Example #2
0
def create_app():
    app = Flask(__name__)

    from models.model import db
    db.init_app(app)

    app.config.from_object('config.DevelopConfig')

    app.register_blueprint(blueprint)
    with app.app_context():
        db.create_all()
    return app
Example #3
0
    def setUp(self):
        db.create_all()
        db.session.commit()
        student = User(id=11, username="******", password=hash_password("password"), firstname="firstname",
                       lastname="lastname",
                       role="student")

        db.session.add(student)
        teacher = User(id=12, username="******", password=hash_password("password"), firstname="firstname",
                       lastname="lastname",
                       role="teacher")
        course = Course(id=11, title="title", filling="filling", creator_id=teacher.id)
        course2 = Course(id=12, title="title1", filling="filling1", creator_id=teacher.id)
        db.session.add(teacher)
        db.session.add(course)
        db.session.add(course2)
        db.session.commit()
Example #4
0
from models.model import db

from flask import Flask, render_template
from views.user import user
from views.statement import statement
from views.landing import landing
from views.bill import bill
from views.transfer import transfer

app = Flask(__name__)
app.config.from_pyfile('config.cfg')

app.register_blueprint(user)
app.register_blueprint(landing)
app.register_blueprint(bill)
app.register_blueprint(transfer)
app.register_blueprint(statement)

if __name__ == '__main__':
    db.init_app(app)
    with app.app_context():
        db.create_all()
    app.run()
Example #5
0
def load_stockprices():

    for key in STOCKS:
        stock_ticker = key
        yql_url = """https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22"""+stock_ticker+"""%22%20and%20startDate%20%3D%20%222015-07-17%22%20and%20endDate%20%3D%20%222015-08-17%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback="""
        req = Request(yql_url)
        result_str = urlopen(req)
        yahoo_stockprice = json.loads(result_str.read())

        stock_dict = yahoo_stockprice['query']['results']
        stock_dict_value = stock_dict['quote']

        for i in range(len(stock_dict_value)):
            stock_date_string = stock_dict_value[i]['Date']
            stock_date = datetime.strptime(stock_date_string, "%Y-%m-%d")
            stock_ticker = stock_dict_value[i]['Symbol']
            stock_close = stock_dict_value[i]['Close']

            new_stockprice = StockPrice(
                stockticker_id=stock_ticker,
                date=stock_date,
                stock_price=stock_close)

            db.session.add(new_stockprice)
        db.session.commit()


if __name__ == "__main__":
    connect_to_db(app)
    db.create_all()
Example #6
0
from flask import Flask, request, render_template, flash, url_for, redirect
from models.model import FeatureRequest, db
import config
from datetime import datetime

app = Flask(__name__)
app.config.from_object(config)
db.init_app(app)
db.create_all(app=app)


def load_features():
    client_a = FeatureRequest.fetch_all("Client A")
    client_b = FeatureRequest.fetch_all("Client B")
    client_c = FeatureRequest.fetch_all("Client C")

    return [client_a, client_b, client_c]


@app.route("/")
def home():
    return render_template("index.html", client_features=load_features())


@app.route("/add/features/", methods=["GET", "POST"])
def add_feature():

    if request.method == "GET":
        return redirect(url_for('home', client_features=load_features()))

    elif request.method == "POST":