When I was conceptualizing the TruthRepo app, I proposed:
- My app will be a bible verse database that categorizes different bible verses and inspirational quotes from Christian authors that apply to different topics or challenges we face in life. Visitors will also be able to add their own quotes and verses.
- This app will be especially useful for the faith-based community when they need help with something more topical or want to share the verses and quotes that have helped them during a challenge/obstacle they have faced.
- I will use python, flask, bootstrap, wtf forms, and SQLAlchemy to present a select menu of topics that will link to that individual record page. I will also include web forms for when users want to add to a record.
- I will start with 15 topics and list at least 3 verses and 2 quotes for each topic.
- To store my data, I will use a MySQL database and manually enter my data.
Here's how I accomplished this:
- I created a MySQL database called truthrepo that contained 3 tables: topics, verses, quotes. I used the tutorials below to relate my tables with one another, as one topic relates to many verses and quotes (one to many relationship).
I created the file structure for my code and started to build my db_app.py file. I imported the necessary technologies I proposed to use and then wrote the code necessary for connecting to my database. Next, I included the necessary code for flask and SQLalchemy.
I created 3 classes that hold my 3 different tables. My first challenge was figuring out how to relate the tables within the 'models'. I used the following tutorials to create foreign keys and relate tables.
I created a 4th class that holds my select menu form. I figured out later that for the menu choices I needed to hardcode the 'topic_id' as the value, and the topic name as the label so I could pass that information through the routes.
I set up 3 routes: '/', '/list', '/topic/' and connected them to the index.html, list.html and topic.html templates, respectfully. This part was definitely the most challenging, as I had trouble using the correct variables and gathering the correct information to pass through to each route and template.
I added two additional classes to the top of my db_app.py file, creating two separate forms that allow the user to add a new verse or a new quote to any topic. I then created two additional corresponding routes that run through the same template: add.html.
I made the page more visually appealing and user-friendly and added error handlers. Next, I put my app on haileyanderton.com. I am very proud of this project and the amount of time I put into it. However, If I was to go back and change anything I would figure out how to get rid of the /list route and template altogether as it is superfluous to the user.