This project running on : https://replit.com/@ViktoriusSuwand/AppBrewery-python-Day-62-CSV-WTF-Form-Bootstrap
Documentation can be found on : https://github.com/viktoriussuwandi/Flask-CSV
* Bootstrap as Front-End CSS Framework
* python Flask as Back-End Framework
* Jinja 2 for data transfer with Front-End and Back-End
* CSV file to load and save data
-
The
home page
should use thecss/styles.css
file to look like this: HINT: Think aboutbootstrap blocks
andsuper blocks
-
The
/cafes
route should render thecafes.html
file. This file should contain aBootstrap table
which displays all the data from thecafe-data.csv
HINT: A object calledcafes
is passed tocafes.html
from the/cafes
route. Try putting it in a<p>
to see what the data in cafes look like. -
The location
URL
should be rendered as an anchor tag<a>
in the table instead of the full link. It should have the link textMaps Link
and thehref
should be the actual link. HINT: All location links have the first 4 characters ashttp
. -
Clicking on the
Show Me!
button on thehome page
should take you to thecafes.html
page. -
There should be a secret route
/add
which doesn't have a button, but those in the know should be able to access it and it should take you to theadd.html
file. -
Use what you have learnt about WTForms to create a quick_form in the
add.html
page that contains all the fields you can see in the demo below:HINT: https://flask-wtf.readthedocs.io/en/stable/quickstart.html https://pythonhosted.org/Flask-Bootstrap/forms.html
-
Make sure that the location URL field has validation that checks the data entered is a valid URL:
HINT: https://wtforms.readthedocs.io/en/2.3.x/validators/
How to switch off client-side (browser) validation with quick_forms: https://stackoverflow.com/a/61166621/10557313
-
When the user successfully submits the form on
add.html
, make sure the data gets added to thecafe-data.csv
. It needs to be appended to the end of the csv file. The data from each field need to be comma-separated like all the other lines of data incafe-data.csv
HINT: https://www.w3schools.com/python/python_file_write.asp