Building my first web app – part three
Okay, I haven’t done any work on this since spending most of Sunday working through a strange bug that caused a few issues. Mostly, I had failed to do two things:
- Set up the database correctly – I had to run the create app function.
- I had called the parameters in some of the functions the wrong names (actually, I had got them around the wrong way)
Building my first web app – part four
So, I have now successfully created the basics of my web app. It has a facility for log in, it restricts web pages to only people who are logged in, and I have added a shopping list function. The next step is to add a to do list function. Again, I would like, at some point in the future, to be able to have different categories, and perhaps even a sortable or searchable function, but that’s beyond the scope of this app. In the meantime, the time has come to add the to do list function. Here’s what I need to do:
- Create a new route in the main.py.
- Actually this will be a few routes – update, delete, post.
- Make sure that this route conforms to the password decorator.
- Create the html page.
- Add the link to the page in the navigation bar on the main page.
- Create the database using SQL
- Make the database live
- Make it all work
Base this on my to do list that I’ve already created.
Just to remember what I’ve got to do
Configuring my environment
- Set up virtual environment in dropbox/keith/technology/python_projects/elsinore
source elsinore/bin/activate
- Configure flask:
export FLASK_APP=project
export FLASK_DEBUG=1
- Run the app
flask run
Setting up the navigation bar
- Inside templates, in the base.html file, I added this.
{% if current_user.is_authenticated %}
<a href=”{{ url_for(‘main.todo’) }}” class=”navbar-item”>
To do
</a>
{% endif %}
Creating a new route in main.py