Farms dataset API management
pip install -r requirements.txt
flask --app farms_api run --debug
pytest
This 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 users
As the result, you will find two files generated by in your directory. Using the example above:
farms_api/routes/users.py
contains the flask routesfarms_api/routes/users_tests.py
contains 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')
...