Skip to content

Miguel Grinberg's Microblog, developed while following his Mega Flask Tutorial.

License

Notifications You must be signed in to change notification settings

ultasun/miguel_mega_flask

Repository files navigation

Miguel Grinberg's Mega Flask Tutorial

Miguel Grinberg had wrote an excellent tutorial series on developing a full stack web application system using the Flask framework.

His system has the reader learn and utilize several components, including Elasticsearch, Redis, RQ and SQLAlchemy.

The system is called Microblog.

Improvements from the original Microblog

The maintainer of this repository had expanded on Miguel's excellent work:

  1. This Microblog will use LibreTranslate to provide translation services to users.
  2. This Microblog provides a stand-alone docker-compose.yml, which allows for easy deployment of the full stack system.
  3. Chapter 23 is about adding a RESTful API to Microblog, but Miguel only shows the implementation for Users, and he leaves the remaining endpoints as an exercise for the reader. The following additional endpoints have been implemented here:
    • /api/posts: read one post, read all posts, publish new post.
    • /api/messages: read one message, read all messages, send new message -- authentication/authorization enabled so that users may only see messages to or from them.
    • /api/notifications: read one notification, read all notifications -- authentication/authorization enabled so that users may only see notifications for them, and no POST method is defined because there's no need for a client to submit a notification.
    • /api/tasks: read one task, read all tasks, submit new task -- authentication/authorization enabled so that users may only see tasks they own. An error will be returned if a client submits the same task twice. The method User.launch_task() is used, just like on the HTML side in routes.py.

Installation

  1. Install Docker, Docker Desktop or Podman,
  2. Download docker-compose.yml,
  3. Download .env.example,
    • Rename it to .env, and then,
    • Place it into the same directory as docker-compose.yml,
  4. Using a terminal, cd to the directory containing both docker-compose.yml and .env, and run:
    • docker compose up
  5. Wait about 15 minutes (or longer) for:
    • All images to download (the LibreTranslate image is large),
    • After the LibreTranslate container starts, it takes about 10 more minutes before it will begin serving translation requests,
  6. Using a web browser, access the service on standard HTTP port 80!

More information

There is an original README.old.md which was used by the maintainer of this repository while following Miguel's tutorial. That README.old.md has notes which, ultimately, have been translated into the run.sh, Dockerfile, docker-compose.yml, and more.

Credits

The original tutorial was written by Miguel Grinberg. All the code in this repository was physically typed on a keyboard by ultasun while following Miguel's tutorial.

Thanks Miguel! Thank you for reading.