Skip to content
Snippets Groups Projects
hanke's avatar
hanke authored
c3151932
History

fsco.li/portal

Development

Setup

with docker

To run a flask shell inside the container:

sudo docker exec -it portal-app-1 flask shell

without docker

# mkdir yourself into the portal directory
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
export FLASK_APP=portal
alembic upgrade head # to create (and update!) the database
flask run

Wichtig:

Alembic must always be up to date in order to update the database schema. Please run alembic upgrade head after pulling changes from the repository.

How to move around in this repo

/portal/: Main Application

Here are all the important tech-stack related stuff and some Python files for Flask, contained in a cozy space

/portal/api/: API Endpoints (Python)

Here you can find the API endpoints, written in Python

/portal/model: database models (Python)

We use SQLAlchemy to interact with the database. The models are defined in this folder.

/portal/static: CSS, JS, images, API documentation

This is giving the frontend some love and, more importantly, its purpose and functionality. The API documentation is also laying around here.

/portal/static/css (CSS, obviously)

Here you can find the CSS files for the frontend. The main CSS file is main.css.

/portal/static/docs

Here you can find the documentation for the API in its respective versions. API specifications (openapi-spec.yaml) are written in OpenAPI 3.0.0 and are located in the /api/{version} folder.

/portal/static/img: Frag nicht, was für Bilder. Einfach Bilder. I won't translate this.

What did you expect?

/portal/static/js: JavaScript files

Lol, that should actually have its own README.

It contains all the JavaScript files that are responsible for the frontend interactions.

/portal/templates

These are the HTML files that Flask renders. They are written in Jinja2, which is a template engine for Python.

.py-files

  • __init__.py: Fortunately, explaining this was not a Prog2 exam question
  • db_config.py: [TODO] Have fun, Jakob. Database configuration (arcane magic).
  • main.py: The Flask server is in here
  • problem_details.py: RFC 7807-compliant problem details responses for the API.