A Flask CMS/blog
The application provides blogging functionality, including:
- Creating, editing and deleting blog posts
- Commenting
- Authenticating to the portal
- Managing posts, users, roles, comments and tags via an Admin Interface
The application is designed to be run under Linux (built with Ubuntu 18.04 LTS). For Windows users, use the Docker deployment option or adjust the steps from source accordingly.
For required Python packages, please see the requirements.txt file.
The testing has been done with MySQL, but any database supported by SQLAlchemy should work with little to no adjustments.
The application requires Redis as its task queue.
-
Ensure you have docker CE and docker-compose installed.
-
Change directory to the folder containing the source
cd samo-cms
-
Set up the environment variables mentioned in *dockerfile-compose.yml.
Run the following command to compose the docker containers
docker-compose up
- The application will be available at http://localhost:8000
- Install the python packages found in requirements.txt. I strongly recommend that you set up a python virtual environment for your projects.
pip install -r requirements.txt
- Set up Redis
For a quick an easy set-up, use Docker as follows:
docker pull redis:latest
docker run --name redis -p 6379:6379 --network samo-network -d redis
, assuming a bridge network samo-network has been created
- Set up a MySQL server.
Again, for a quick set-up, use Docker as follows:
docker pull mysql:latest
docker run -p 3306:3306 --name some-mysql -e MYSQL_ROOT_PASSWORD=$SAMO_DB_PASS -d mysql:latest
Create a database named 'samo'.
- Configure the environment variables as follows:
- FLASK_ENV=development
- all the environment variables mentioned in config.ini.example
- Run the management commands as follows
python manage.py initdb
this will initialize the database (create the database objects)
python manage.py create_admin
this will create an admin user with the following credentials. Please remember to remove it as soon as the setup is complete.
* username="admin",
* email="admin@example.com"
* password="admin"
-
Run the Celery Worker
cd ./samo-cms/ source venv/bin/activate celery worker -A samo.core.celery --loglevel=info
-
The final step would be starting the application by running
python run.py
The samo-cms/manage.py file executes basic managing tasks, including:
- initdb - initializes the databases
- create_admin - creates an admin user with the following credentials. Please remember to remove it as soon as the setup is complete.
- username="admin",
- email="admin@example.com"
- password="admin"
- dropdb - DROPS all tables
Usage example:
python manage.py initdb
&&
python manage.py create_admin
Also, the manage.py file is the interface to Flask-Migrate for database migrations. Commands should start with
python manage.py migrations
, for example in order to establish an initial migration, run:
python manage.py migrations init
Samo-CMS started as a learning by doing project. The following resources, among others, proved of great help:
- Reindert-Jan Ekker's course "Introduction to the Flask Microframework" on Pluralsight and the boilerplate project I've built while following his course.
- Miguel Grinberg's excellent, extensive tutorial on Flask
- Realpython - great, detailed instructions
- Nick Janetakis' blog