codelucas / flask_reddit

Reddit clone in flask + python + nginx + https. View site:
https://reddit.codelucas.com
MIT License
530 stars 106 forks source link
flask flask-python flask-reddit python reddit

flask_reddit

flask_reddit is an extendable + minimalist Reddit clone.

This was built so beginners who want a standard CRUD + reddit-like application can quickly get to work.

We utilize:

And thats pretty much it!

All of the configutations are in this repository. Deployment instructions will be out soon.

Features

Build Instructions

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mysql-server libmysqlclient-dev

sudo apt-get install nginx

sudo apt-get install supervisor

sudo apt-get install python-virtualenv;
cd /path/to/project;
virtualenv reddit-env;
cd reddit-env;
source bin/activate; # viola, you are now in an enclosed python workspace.
git clone https://github.com/codelucas/flask_reddit.git;
cd flask_reddit;
pip install -r requirements.txt

python2.7 kickstart.py

A crontab is a dash which allows you to specify what programs to run and how often. I've provided flask_reddit's example crontab in the root directory as jobs.cron.

To view your current crontab, run crontab -l. To edit your crontab, run crontab -e.

sudo sh run_gunicorn.sh

Note that we have now deployed two servers: nginx and gunicorn. nginx is our internet facing HTTP server on port 80 while gunicorn is our wsgi server which is serving up our flask python application locally. nginx reads client requests and decides which requests to foreward to our gunicorn server. For example, nginx serves static content like images very well but it forwards url routes to the homepage to gunicorn.

For a full list of details, view our configs at server/nginx.conf and server/gunicorn_config.py.

Note, for this build to work there are paths that you must change in the wsgi.py file, the server configs located in server directory and the run_gunicorn.sh file.

Refer to the flask project configuration options to understand what to put in your own config.py file.

Do not hesiate to contact me for help or concerns.