Output a list
Create a shopping list and let pyton print it to the command line
- Create a List and populate it with the fruit and veg Mum needs in this weeks shopping trip.
- Define a function to print out the list to the command line and call it from
__main__
- Run the app
python3 main.py
- Output should be
['EGGS X24', 'FRUIT', 'BANANAS', 'BERRIES', 'CUCUMBERS', 'LETTUCE', 'SQUASH (1/2)', 'MUSHROOMS', 'POTS', 'ASPARAGUS X2', 'LEEKS', 'SWEET POTS', 'FRESH PINEAPPLE', 'TOMS']
`
- Import Flask and use pip to install it
pip3 install flask
- Follow the Quickstart example in the Flask docs to create a simple flask page
- Replace the
hello world
function with one that outputs your list to the page as a string using''.join(shopping_list)
- Observe output is not readable, all the items are smooshed together in one line
- Modify the function to build an
output
String from the list as an unordered list<ul>
in HTML
- Commit your code to git
git init && git commit -m 'initial shopping list flask app'
- Push to a public repo
git remote add origin [MY_REPO] && git push