-
Notifications
You must be signed in to change notification settings - Fork 0
Back End
The back end of our website was implemented using Flask and Python. Flask is a web development framework that uses Python to create the back end of a website. Flask comes with a development server that allows for local testing of the web development without using a web server. All development was done in this local server and the changes were pushed to the github repo when the development was complete.
We used Flask to handle the linking between the pages of our website. In order to do this, we first structured our gitub repo such that there were three main directories, one called "templates" which contained all of the .html pages, another called "static" which contained all images, javascript, and css pages, and another called "venv" which contained all of the packages that come with Flask. This must be done so that the Flask package can effectively link the html pages together using its built in routing functions.
We then wrote a Python script called "app.py", saved outside of the three directories that were mentioned above, in which we defined all of the functions that were used to link pages together. In this script, we defined a routing function for each html page using the render_template() function and the @app_route() decorator. The following example shows how this was done for the scientist table page, whose html page is called "scientists.html".
@app_route(/scientists)
def scientists():
return render_template("scientists.html")
The argument of the @app_route() decorator specifies the url extension that will be associated with the html page referenced in the linking function defined below. So in this case, the url path to the scientists page will be sciencebois.me/scientists. The argument of the render_template() function is the html page that should be displayed when the url specified in the decorator is accessed. So in this example, when sciencebois.me/scientists is typed in the address bar of a browser, Flask will display the html page "scientists.html".
We then used these linking functions to create links between pages. The following example will show how we created a clickable hyperlinked word "scientists" that when clicked will take you to the url sciencebois.me/scientists.
<a href = {{url_for("scientists")}}>scientists</a>
The double curly braces tell Flask that what lies inside is a command. The url_for function then returns the url associated with its argument, which is the linking function "scientists" in this example.
