Skip to content

This is a simple tech blog that also allows a user to post comments and receive feedback.

License

Notifications You must be signed in to change notification settings

GitauHarrison/somasoma-tech-blog

Repository files navigation

somaSoma Tech Blog

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.

Somasoma Home Page

Features

  • 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

Tools Used

  • 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

Features Lacking

  • Markdown support for blog posts
  • Blog post editing
  • Two-factor authentication
  • Multi-upload of files

Deployment

License

  • MIT

Contributors

Run the Application Locally

  1. Clone the project
$ git clone git@github.com:GitauHarrison/somasoma-tech-blog.git
  1. Move into the cloned directory
$ cd somasoma-tech-blog
  1. Create and activate a virtual environment
$ mkvirtualenv venv # I am using virtualenvwrapper
  1. Install project dependencies
(venv)$ pip3 install -r requirements.txt
  1. Update environment variables following the template seen in .env.template

  2. Run the application

(venv)$ flask run # from the top-level directory
  1. See the application
# Paste the following into a browser: http://127.0.0.1:5000/
  1. 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
  1. 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.

Testing the Application

See Video

References

You can add the lacking features to your flask blog. Check out some of these resources to get started:

If you are just starting out in Flask, consider this:

About

This is a simple tech blog that also allows a user to post comments and receive feedback.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published