abhishekb91 / microblog

A microblog written in Flask

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Microblog

A web app written using Flask:

Contents

Installing Application

To ensure all the configuration is passed as an environment variables to the application, we will create a local .env.dev file which gets passed to the container as a env_file. Copying the content of .dev.dev-sample and make changes as required according to your local machine.

Once we've made the environment file, we need to install docker in your local machine to create containers which hosts the application and all the dependencies. Once docker is installed, go the project root directory and run:

docker-compose build

This command will download all dependencies and will install the application in docker container.

Starting Application

Once we've installed the application using docker-compose build, we can easily start the application by:

docker-compose up -d

This will start the application, database and elasticsearch in detached mode

Reindexing Models

After the application is installed and running, we need to update the indexes for searching to work. For this let's reindex all the models used for searching

Currently we support searching in

  • Posts

Since the application is running in a container we created, we first need to connect to the microblog_flask_app container which host our application. Ensure the application is running, go to the project root directory and execute:

docker exec -it microblog_flask_app bash

This connects to the microblog_flask_app container in interactive mode so that we can run/check the application. In order to reindex the POST, we'll use flask shell command from the container:

$ flask shell
Python 3.8.0 (default, Nov 15 2019, 02:22:06)
[GCC 8.3.0] on linux
App: app [development]
Instance: /home/microblog/instance
>>> Post.reindex()
>>> 

Unit Tests

The unit tests are written in the tests.py using python's unittest module and can by connecting to the container and executing:

python tests.py

About

A microblog written in Flask

License:MIT License


Languages

Language:Python 71.4%Language:HTML 25.8%Language:Mako 1.0%Language:Shell 0.9%Language:Dockerfile 0.9%