Contains the data for our application
dwarf-data.mdcontains data on the dwarf planetsplanets-data.mdcontains data on the planets of the solar systemrandom-facts.mdcontains a list of random solar system facts
Contains the HTML files that will be rendered for the frontend.
layout.htmlcontains a shared layout for each page. Do not edit this.index.htmlis the homepage. No need to edit this.planet-list.htmlis the page that will display the list of planets [TODO]dplanet-list.htmlis the page that will display the list of dwarf planets [TODO]random-fact.htmlwill display a random fact [TODO]edit-planet.htmlwill allow the user to edit the entry for a planet [TODO]error.htmlwill just display any errors. No need to edit this.
Contains the (singular) CSS file needed for our application's styling: styles.css
This can be extended to add more styles, either to styles.css or in a different stylesheet file.
General note:
/static/ is meant to contain all static files; generally it contains 3 main subfolders styles (for CSS stylesheets), scripts (for JavaScript code) and media (for images, videos, etc.). We do not have any JS scripts or any media for now, but feel free to add your own.
This will eventually contain the forms we need for our application. We will work on this during the workshop.
Some useful functions that handle reading/writing data, conversion to different formats, etc. Do not edit this.
Our Flask application will be written here. We will work on this during the workshop.
TODO: If you have time, read through app.py to get an idea of what will happen during the workshop.
Like Wikipedia, but less extensive. Users can read about the planets in the solar system and edit entries that appear to be erroneous.
A route is a URL pattern.
A handler is a function that handles requests made to a particular route.
The table below matches each route in the application to its handler as well as the relevant HTML file (if any).
| Route | Handler | HTML File (if any) | Description |
|---|---|---|---|
/ |
hello |
index.html |
Homepage of the application. |
/leave |
leave |
None (redirects elsewhere) | Leave the application. |
/random-fact |
get_random_fact |
random-fact.html |
Get a random solar system fact. |
/planets |
planets |
planet-list.html |
Get the list of planets. |
/dwarf-planets |
dwarf_planets |
dplanet-list.html |
Get the list of dwarf planets. |
/edit/planet/<planet_name> |
edit_planet_entry(planet_name) |
edit-planet.html |
Allow user to edit an entry about a planet. |
Note: We will do this during the workshop as well. No need to do this in advance.
- Ensure you have Python 3.10+ installed on your system, along with
pip. - Clone/fork/download the source code from this repository.
cdinto the folder with these files such thatapp.pyappears in the working directory.- Create a Python virtual environment:
On Linux/MacOS:
python3 -m venv .venvOn Windows:
py -m venv .venv- Activate the virtual environment:
On Linux/MacOS:
source .venv/bin/activateOn Windows:
.venv\Scripts\activate- Install the necessary modules:
pip install flask flask-wtf wtformsOr, from the requirements.txt:
pip install -r requirements.txt- Turn on debug mode for Flask:
On Linux/MacOS:
export FLASK_DEBUG=1On Windows:
set FLASK_DEBUG=1- Run the command
flask run, and then open up a browser and go to the URLhttp://localhost:5000/. The application should be set up if ALL previous instructions have been followed.