Search⌘ K
AI Features

Flask for Static Content

Explore how to modify your Flask application to serve static content alongside dynamic routes. Understand configuring static file locations, adjusting default routes for single-page applications, and running your server with Gunicorn on port 8080. This lesson helps you handle simpler deployments without separate web servers.

While not necessarily recommended for heavily used applications, it is possible to forgo the web server for serving static content and just use the application server to serve the static content along with the dynamic content. The main thing we would lose in this case is scalability and perhaps a bit of performance.

About the application

In this application, we’ll look at some modifications in our appserver.py module to specify the location of the static files to be served in our application. We will also look at a slight modification regarding the change in default route from / to /api. Lastly, we will look at how we can bind our server on a 8080 port using Gunicorn.

This is what the application looks like:

Note: To log in, use the username admin ...