This Flask application displays my family's favorite recipes! Frozen-Flask is used to generate the static files based on the routes specified in the Flask app. These static files are hosted on Netlify:
For details on how this Flask app generates static files, check out the Generating a Static Site with Flask and Deploying it to Netlify blog post on TestDriven.
https://www.kennedyrecipes.com/
Pull down the source code from this GitLab repository:
git clone [email protected]:patkennedy79/flask-recipe-app.git
Create a new virtual environment:
$ cd flask-recipe-app
$ python3 -m venv venv
Activate the virtual environment:
$ source venv/bin/activate
Install the python packages in requirements.txt:
(venv) $ pip install -r requirements.txt
Run development server to serve the Flask application:
(venv) $ flask --app app --debug run
Navigate to 'http://127.0.0.1:5000/' in your favorite web browser to view the website!
- Flask: micro-framework for web application development which includes the following dependencies:
- click: package for creating command-line interfaces (CLI)
- itsdangerous: cryptographically sign data
- Jinja2: templating engine
- MarkupSafe: escapes characters so text is safe to use in HTML and XML
- Werkzeug: set of utilities for creating a Python application that can talk to a WSGI server
- Frozen-Flask - generates static files from Flask routes
- Markdown - text-to-HTML conversion tool
- pytest: framework for testing Python projects
- pytest-cov: pytest extension for running coverage.py to check code coverage of tests
- flake8: static analysis tool
This application is written using Python 3.11.0.
To run all the tests:
(venv) $ python -m pytest
To check the code coverage of the tests:
(venv) $ python -m pytest --cov-report term-missing --cov=project
- Add the new image to project/static/img/.
- Copy project/recipes/template/markdown/recipe_starter.md to a new file in the same directory with the recipe name as the filename.
- Update the new project/recipes/template/markdown/<recipe_name>.md file with the recipe description, ingredients, and steps.
- Generate the HTML file for the new recipe:
$ python project/recipes/templates/md_to_html.py
- Add a new section to the applicable recipe section HTML file (i.e. project/recipes/template/recipes/baked_good.html, project/recipes/template/recipes/dinner.html, etc.).
- Add the recipe name to the top of project/recipes/routes.py.
- Update the number of recipes for the applicable recipe section in project/recipes/template/recipes/recipes.html.
Lastly, run the tests to make sure everything is working as expected:
(venv) $ python -m pytest
In the top-level directory, run the build script:
(venv) $ python build.py
The static files are generated in the /project/build/ directory, which can then be hosted on Netlify.