I use this project for my own personal blog, however, it is not really tailored to the core for my own specific needs.
It can still serve as a simple, general-purpose blog for almost anyone out there.
It can also be of great use if you'd like to play around with Python, Flask or web development in general.
I accept pull requests (See CONTRIBUTING.MD for more)
Visit julianhysi.com to see the deployed application.
Note: the production source code has a few deplyoment tweaks compared to this repo.
- create, edit and delete an account/profile
- auth system, reset password
- create, edit and delete posts (admin only)
- create, edit and delete books (admin only)
- comment on a post (users only)
- full-text search posts
- add tags to the post when you create it, update tags
- view posts (by user, by tag, sorted by date, paginated)
- Python 3.x
- Flask
- Jinja2
- SQLite
- SQLAlchemy
- ElasticSearch
- HTML5 and Boostrap 4
follow all these steps to set up a contribution workflow
skip to the Docker workflow at the end, if you simply want to run the app
- clone the repo locally and cd to its folder
- hit
python -m venv venv
to create a virtual environment - hit
source venv/bin/activate
to activate the virtual environment - while the environment is activated, hit
pip install -r requirements.txt
to install dependencies - hit
pip list
to verify the dependencies have been installed - set environment variables (see section below)
- install, config and run Elastic server following this guide: (https://tecadmin.net/setup-elasticsearch-on-ubuntu/)
- hit
export FLASK_APP=run.py
- hit
flask db upgrade
to create the db schema - see section below on how to run the application
SECRET_KEY
(random hex that should be kept secret, see Flask docs for more)DATABASE_URI
(sqlite database uri, set it tosqlite:///static/db/blog.db
)
the following 3 variables are necessary only if you want the full functionalityMAIL_USERNAME
(the email account used for sending emails to users, needed by the password reset feature)MAIL_PASSWORD
(the email password used for sending emails to users, needed by the password reset feature)ELASTICSEARCH_URL
(elastic database url, needed by search feature, you may usehttp://localhost:9200
)
- make sure you have the above mentioned dependencies installed, and the virtual env activated
- in the project's top level directory, hit
python run.py
- the server should start, and you can access the localhost port 5000 on a browser to see the app
this workflow is a simpler alternative to the contribution workflow from above
- install Docker (https://linuxize.com/post/how-to-install-and-use-docker-on-ubuntu-20-04/)
- hit
docker build -t personal_blog:latest
to build an image off of Dockerfile - set environment variables (see section above)
- pull an elastic image:
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.12.1
- run an elastic container:
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -d --rm -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.12.1
and wait a few seconds - hit
bash docker_run.sh
and access the app on the given port