Farms dataset API management
pip install -r requirements.txtflask --app farms_api run --debugpytestThis application offer CLI functions to speed up your setup based on the principals and architecture based to build this project.
From root folder, execute the command line bellow. Remind to fill up with the name you want to create.
python scaffolding/generate_routes.py <name>
# Example
python scaffolding/generate_routes.py usersAs the result, you will find two files generated by in your directory. Using the example above:
farms_api/routes/users.pycontains the flask routesfarms_api/routes/users_tests.pycontains the tests related to the routes created
Do you need to change the app configuration manually. Open farms_api/__init__.py and add your new routes paths to the
main Flask application.
# farms_api/__init__.py
...
# Import the new routes created
from farms_api.routes.users import users_blueprint
def create_app(test_config=None):
# create and configure the app
app = Flask(__name__, instance_relative_config=True)
app.config.from_mapping(
SECRET_KEY='dev',
DATABASE=os.path.join(app.instance_path, 'flaskr.sqlite'),
)
app.register_blueprint(farmers_blueprint, url_prefix='/api')
app.register_blueprint(addresses_blueprint, url_prefix='/api')
# add the new routes imported to the main app
app.register_blueprint(users_blueprint, url_prefix='/api')
...