Blog API (Flask tutorial)

Thos project is based on the Flask Tutorial, adapted to be a backend-only for the blog app.

Requirements

Installation (Python)

  1. Install Miniconda if not already installed;
  2. Create a Conda virtual environment with Python 3.10: conda create -n blog python=3.10 -y
  3. Activate the environment and install the requirements: conda activate blog; pip install -r requirements.txt

Running the application locally

To run in your own machine (without Docker):

  1. Activate the Conda virtual environment (if not active already): conda activate blog
  2. Synchronize the changes to the SQLite database: flask db upgrade
  3. Run Flask: flask --app app run --debug
  4. Access http://localhost:5000/apidocs
  5. Press Ctrl+C in the Terminal to quit Flask

Run the application using Docker

  1. Run docker compose up to run the application
  2. Access http://localhost:5000/apidocs

Project structure

app
  - __init__.py         # main application file
  - globals.py          # global objects
  - modules             # each application module/route group
    - user              # user and authentication
      - model.py        # model definitions
      - resource.py     # routes
    - post
      - model.py
      - resource.py
  - instance
    - blog.sqlite       # SQLite database (not included in Git)
  - migrations          # database migration files
    - ...               # files generated by Flask-Migrate package

Libraries used