Exemplo n.º 1
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])

    api = Api(app)

    api.add_resource(User, '/api/user/<string:name>')
    api.add_resource(Users, '/api/users/')

    db.init_app(app)
    ma.init_app(app)

    with app.app_context():
        db.create_all()

    return app
Exemplo n.º 2
0
from flask import Flask
from flask_restful import Api

from resources.user import User, Users

app = Flask(__name__)
api = Api(app)

api.add_resource(User, "/user/<string:name>")  # <a:b> no blank
api.add_resource(Users, "/users/")

if __name__ == "__main__":
    from common.ma import ma
    ma.init_app(app)
    app.run()