import os from os import sys, path from flask_migrate import Migrate, MigrateCommand, Manager from flask_sqlalchemy import SQLAlchemy try: sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) from .src import create_app except ImportError: from app.src import create_app app = create_app(os.environ['UPLOAD_FOLDER'], os.environ['DB_FOLDER']) db = SQLAlchemy(app) migrate = Migrate(app, db) manager = Manager(app) manager.add_command('db', MigrateCommand) class File(db.Model): id = db.Column(db.Integer, primary_key=True) mimetype = db.Column(db.String(64), index=True, unique=False) path = db.Column(db.String(120), index=True, unique=True) def __repr__(self) -> str: return self.filepath if __name__ == "__main__":
""" Application entry point """ import os from flask_cors import CORS from app import blueprint from app.src import create_app app = create_app(os.getenv("FLASK_ENV") or "development") app.register_blueprint(blueprint) CORS(app, resources={"/ping/*": {"origins": "*"}}) app.app_context().push() if __name__ == "__main__": app.run()
import os from flask_migrate import Migrate, MigrateCommand from flask_script import Manager from app import blueprint from app.src import create_app, db from app.src.model import polygon, location, matrix_row flask_app = create_app(os.getenv('BOILERPLATE_ENV') or 'dev') flask_app.register_blueprint(blueprint) flask_app.app_context().push() manager = Manager(flask_app) manager.add_command('db', MigrateCommand) migrate = Migrate(flask_app, db) @manager.command def run(): flask_app.run() if __name__ == '__main__': manager.run()
import os from app.src import create_app, db from app import blueprint application = create_app(os.getenv('FLASK_ENV')) application.register_blueprint(blueprint)
import os import unittest from flask_migrate import Migrate, MigrateCommand from flask_script import Manager from app.src import create_app, db from app.src.model import user from app import blueprint app = create_app('dev') app.register_blueprint(blueprint) app.app_context().push() manager = Manager(app) migrate = Migrate(app, db) manager.add_command('db', MigrateCommand) @manager.command def run(): app.run() db.create_all() @manager.command def test(): """Runs the unit tests.""" tests = unittest.TestLoader().discover('app/tests', pattern='test*.py') result = unittest.TextTestRunner(verbosity=2).run(tests) if result.wasSuccessful(): return 0 return 1 if __name__ == '__main__': manager.run()
import csv import os import unittest from flask_migrate import Migrate, MigrateCommand from flask_script import Manager from app import blueprint from app.src import create_app, db from app.src.users.models import User from app.src.states.models import State from app.src.states.preloader import preload_data app = create_app(os.getenv("APP_ENV", "dev")) app.register_blueprint(blueprint) app.app_context().push() manager = Manager(app) migrate = Migrate(app, db) manager.add_command("db", MigrateCommand) @manager.command def load_initial_data(): "Load initial data into database." with open("states.csv", "r") as states_file: preload_data(csv.reader(states_file))
""" Application entry point """ import os from flask_cors import CORS from flask_script import Manager from app import blueprint from app.src import create_app app = create_app(os.getenv("FLASK_ENV") or "development") # pylint: disable=invalid-name app.register_blueprint(blueprint) CORS(app, resources={"/ping/*": {"origins": "*"}}) app.app_context().push() manager = Manager(app) # pylint: disable=invalid-name @manager.command def run(): """ Command to run the server at localhost:5000 for default values. $ python manage.py run """ app.run() if __name__ == "__main__": manager.run()