Flask server that allows for the storage of quotes
This is my first attempt at a Flask application that is larger than a single file.
My friends and I have had a quote board that we fill with our absurd sayings for quite some time, but we would often forget to add quotes that were said outside of the apartment/dorm, or sometimes we just wanted to get the exact wording on that insane thing that Liam said. This seemed like a quick way to solve those problems.
-
Run the Flask app as you usually would
-
A new file will be created in the root directory of the project (
quotes.db
) -
This file is the SQLite database that the app uses to keep track of quotes
-
There is no special setup for the database, the app should handle everything.
-
'/newquote' [POST] - Route to post new quotes to to be added to the database
-
'/' [GET] - Home page that display quotes
-
'/submitquote' [GET] - Page that has form to submit quotes
-
'/filter/name/<name>' [GET] - Same as home page, but filters for quotes that contain
name
in the author section -
'/filter/text/<text>' [GET] - Same as homepage, but filters for quotes that contain
text
in the text section
I chose to store the quotes in a SQLite database for a few reasons. They're fast, efficient, and easy in Python.
I had never really used Flask for anything more than one file projects, so this was a nice introduction to the idea of that.
In general, I don't have much experience with backend development. I figure that it'll be a great set of skills to have.
I have just recently come around to Python, so I wasn't very familiar with the way Python handles modules and packages. This project led me to learning what those words mean to Python and how to use each of them, which will definitely come in handy.
-
quote.py
- Quote object and helper functions for reading and writing quotes -
routes.py
- Routes and code associated with handling all route in the app -
__init__.py
- Handles WSGI app creation -
static/
- Directory for static content -
templates/
- Directory of Jinja templates
I did this as a rudimentary way of making quote submission exclusive to those who are participants in the website. This way when someone stumbles upon it, there is no greifing that can be done from the homepage.
-
Clean up everything. This was made when I was new to web frameworks and databases, so this needs a good refactoring
-
Figure out how to design search so that it has the option to search by text