from flask_script import Manager from flask_migrate import Migrate, MigrateCommand from server.application import db, create_app, init_app from server.config import configure_app application = create_app() configure_app(application) init_app(application) migrate = Migrate(application, db) manager = Manager(application) manager.add_command('db', MigrateCommand) if __name__ == '__main__': manager.run()
import csv from server.app.models import Listing from server.app.models import get_or_create from server.application import create_app from server.application import db from config import BaseConfig app = create_app(BaseConfig) db.init_app(app) with app.app_context(): with open("listing-details.csv", "rb") as csvfile: reader = csv.reader(csvfile) for listing in reader: print("Loading %s" % str(listing)) try: get_or_create(Listing, property_id=listing[0], street=listing[1], status=listing[2], price=int(listing[3]), bedrooms=int(listing[4]), bathrooms=int(listing[5]), sq_ft=int(listing[6]), lat=float(listing[7]), lng=float(listing[8])) except ValueError as err: print("Error loading line: %s" % err)
def create_app(self): return create_app(TestConfig, debug=True, testing=True)
from server.application import create_app app = create_app(settings='server.config.Production')
#!/usr/bin/env python # -*- coding: utf-8 -*- from server.application import create_app from flask import render_template app = create_app() @app.route('/') def index(): return render_template('index.html') if __name__ == '__main__': app.run()
from server.application import db, create_app from config import BaseConfig db.create_all(app=create_app(BaseConfig))
from server.application import create_app from server.application import db from config import BaseConfig db.create_all(app=create_app(BaseConfig))