from flask import jsonify from marshmallow import ValidationError from ma import ma from db import db from controllers.book import Book, BookList from controllers.client import Client, ClientList from server.instance import server api = server.api app = server.app @app.before_first_request def create_tables(): db.create_all() api.add_resource(Book, '/books/<int:id>') api.add_resource(BookList, '/books') api.add_resource(Client, '/clients/<int:id>') api.add_resource(ClientList, '/clients') if __name__ == '__main__': db.init_app(app) ma.init_app(app) server.run()
import argparse from server.instance import server from util.util import validate_env_name if __name__ == '__main__': parser = argparse.ArgumentParser( description='Read application environment') parser.add_argument( '--env', dest='env', default='dev', type=validate_env_name, help='Valid environment values: dev, stg and prod. Default is dev.') args = parser.parse_args() env_name = args.env server.run(env_name)