Final Project
For this project you will use what we have learned so far this semester to create a web site using Flask and SQLite. This project is open-ended, but for full credit you must adhere to the requirements below. The project is due Friday, May 1.
It was originally going to be required that this project be a group project, but given the circumstances I will not require that everyone work in groups. However, some students have expressed interest in working in groups. So you may work individually, or in a self-selected group of 2 or 3 people.
Either way, please contact me by Monday, April 20 with your project idea, and list the members of your group if you are working in a group.
Requirements
Your Flask application must serve both HTML web pages and implement an API that uses JSON. The HTML pages will allow users to interact with the content in the database through the browser, and the API will allow applications to interact with the site.
You must also create a command-line utility that interacts with the site via the API.
More detailed requirements:
- Your database must have at least 3 tables that are linked via foreign keys
- Your application must create a fresh instance of your database if the Flask app is started and the database file does not yet exist.
- You must create a class to encapsulate access to your database (similar to the
DogDatabase
class) - You must write pytest tests that demonstrate the correctness of your code (I encourage you to write these tests as you go rather than wait to write them at the end!)
- Your Flask application must present information from your database as a web page using an HTML template (look back at the Browse Dogs assignment for a refresher). You may have several pages if you wish.
- Your Flask application must provide an API for accessing and modifying the data in your database.
- You must create a command-line application that uses Python’s
requests
module to use your API. This application must do one or more of the following:- Present information in some way
- Add information to the database (either from a file, such as a CSV file, or by asking the user for input)
- Modify information in the database
- You must use a feature of one of these technologies that we have not discussed in class (see below). You must use an additional feature for each additional member in your group (a group of 2 must use 2 additional features, and a group of 3 must use 3)
- Your code must be well documented, including documentation for your API
- Your code must adhere to PEP 8
- Your code must be in a GitHub repository under the class organization (see below for more details)
GitHub Repository
You must create a repository on GitHub in which you will work. Create the repository as a private repository under the class organization (https://github.com/cs232s20/). If you are working as a group, whoever creates the repository must add the other team members to the repository with write access.
It is always a good idea to create a .gitignore
file in your repositories so that certain files will be ignored by Git, preventing you from accidentally adding files that should not be in the repository. For example, things will get annoying if someone accidentally pushes their PyCharm project folder. You also do not want to add SQLite databases, since those can be created from the code.
Here are the contents of a .gitignore
file which will ignore the PyCharm project folder (.idea
), compiled Python bytecode (*.pyc
), the Python cached bytecode folder (__python__
), SQLite databases (*.sqlite
), and macOS folder attributes (.DS_Store
):
.idea/
*.pyc
__pycache__
*.sqlite
.DS_Store
You can create your .gitignore
before anybody forks the repository by clicking the “Create new file” link at the top of the repository.
If you are working in a group, all development must be done in personal forks of this repository. When you have code that should go into the main repository, create a pull request. The pull request must be merged by someone else in the team, and everyone must merge at least one pull request.
Once your repository is created, have one of the team members send me an email with the name of your repository and the members of your team.
Dividing Work and Simultaneous Development
If you are working in a group, work will need to be divided up among the team members. Some of the components will ultimately depend on other components, but that should not stop you from starting work on those components. For example, the HTML templates will ultimately need to use data from the Flask code, but you can write HTML files that are filled in with fake placeholder data at first, and then add the template stuff later when the Flask code is ready to use it. If you open up the HTML file on your computer it will open in your browser, so you can get things looking nice before it uses live data.
Similarly, the Flask code will ultimately need to use the database class, but you can still start working on the Flask code by manually returning fake data until the database code is written.
There will be a git-keeper assignment in which those who are working in a group will be required to submit a short write-up detailing which portions of the project they were responsible for.
Additional Features
Some features that we have not yet talked about that you might incorporate into your project:
- Creating an HTML page with a form that can be used to add information to the database
- User accounts (if you are going to store passwords they must be salted and hashed!)
- Making your web site fancier with CSS and/or Javascript
- Adding a rate limit to your API
- SQLite triggers
You can find other features to use as well. If you are unsure if your idea fulfills this requirement, ask me.
Create a file named features.md
in your repository where you write an explaination of the feature(s) that you chose and how you incorporated them into your project.
Ideas
If you are stuck trying to think of an idea for your project, here are some suggestions. Remember to keep it simple! Start by developing the simplest version of your idea that you can think of and add more features if you have time.
- A message board
- An inventory management system
- A site to manage a music collection
- An online survey system