This is a simple tech blog. It features an admin who can remotely update the blog. Anonymous users can interact with the blog contents using the user forms in each blog post.
- Anonymous user can post comments
- Admin authentication and authorization
- Admin session management
- Database Management
- Pagination of some contents
- File Upload
- Password reset
- Credit card payment
- Flask microframework
- Python for programming
- SQLite3 database (during development)
- Flask WTF forms
- Flask Bootstrap for styling and cross-browser responsiveness
- Moment.js for date formatting
- Gunicorn and Psycopg2 for live deployment
- Flask mail for sending emails locally (for live deployment, you will need Twilio Sendgrid)
- Stripe for credit card payment
- Markdown support for blog posts
- Blog post editing
- Two-factor authentication
- Multi-upload of files
- Somasoma on Heroku
- Somasoma tech blog - Render
- MIT
- See all contributors here
- Clone the project
$ git clone git@github.com:GitauHarrison/somasoma-tech-blog.git
- Move into the cloned directory
$ cd somasoma-tech-blog
- Create and activate a virtual environment
$ mkvirtualenv venv # I am using virtualenvwrapper
- Install project dependencies
(venv)$ pip3 install -r requirements.txt
-
Update environment variables following the template seen in
.env.template
-
Run the application
(venv)$ flask run # from the top-level directory
- See the application
# Paste the following into a browser: http://127.0.0.1:5000/
- Intersted in testing the locally running application on another device? Run the command below in your terminal:
(venv)$ ngrok http 5000
NOTE:
You will see this output:
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Session Expires 1 hour, 59 minutes
Version 2.3.40
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://3472-197-237-0-37.ngrok.io -> http://localhost:5000
Forwarding https://3472-197-237-0-37.ngrok.io -> http://localhost:5000
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
There are two public URLs being mapped to localhost. These URLs begin with the word Forwarding.
Forwarding http://3472-197-237-0-37.ngrok.io -> http://localhost:5000
Forwarding https://3472-197-237-0-37.ngrok.io -> http://localhost:5000
Paste, for example, "https://3472-197-237-0-37.ngrok.io" on another device such as your phone. You should be able to see the application running. If not, you will be required to sign up for an ngrok account (in case you haven't already) and install your authtoken
. It is actually very simple:
- Download ngrok for your operating system
- Extract the ngrok binary on linux or Mac OS X (on Windows, you double-click the .exe file)
- Connect your account
- Fire it up
- Want to start ngrok when the server fires up?
Uncomment these lines in app/__init__.py (51 - 58)
# def start_ngrok():
# from pyngrok import ngrok
# url = ngrok.connect(5000)
# print('* Tunnel URL: *', url)
# if current_app.config['START_NGROK']:
# start_ngrok()
Note that if you uncomment these lines, you can skip step 8 above, because ngrok will start authomatically when you fire up the flask server. You will see ngrok public URLs in your terminal.
You can add the lacking features to your flask blog. Check out some of these resources to get started:
- Learn how to add two-factor authentication to your Flask application here
- Learn how to integrate comment moderation to your flask blog
- Add markdown support to your flask forms
- Testing your locally running flask application on another device
If you are just starting out in Flask, consider this: