• Stars
    star
    530
  • Rank 83,660 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Reddit clone in flask + python + nginx + https. View site:

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:

  • flask as the web framework.
  • nginx as the HTTP server
  • gunicon as the wsgi server.
  • MySQL for our database
  • flask-sqlalchemy as our ORM.
  • bootstrap-journal theme makes us beautiful.
  • virtualenv emcompasses everything.
  • supervisord makes sure our service never crashes.

And thats pretty much it!

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

Features

  • threaded comments
  • up voting
  • subreddits
  • user karma
  • search
  • rate limiting
  • ajax form posting
  • user profiles

Build Instructions

  • Set up an instance of MySQL on your server. Note your username and password.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mysql-server libmysqlclient-dev
  • Set up an instance of nginx on your server. I've provided the .conf scripts needed for our servers in the /server directory.

sudo apt-get install nginx

  • Configure your nginx settings located in flask_reddit/server/nginx.conf.

  • Add your settings into your global conf file located in /etc/nginx/nginx.conf

  • Restart nginx to recognize your settings sudo service nginx restart

  • Set up supervisord to monitor your project to make sure it never crashes. Supervisor is also convenient for simply restarting/starting your project with ease.

sudo apt-get install supervisor

  • When Supervisor is installed you can give it programs to start and watch by creating config files in the /etc/supervisor/conf.d directory. I've provided the conf file which we use in the root directory of this repo as supervisor.conf. An example supervisor command would be running supervisorctl restart YOUR_APP_NAME to restart gunicorn and bring up new changes.

  • Install virtualenv and set up a project root where ever you want.

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.
  • Download the repository and install all of the required python modules which this server uses.
git clone https://github.com/codelucas/flask_reddit.git;
cd flask_reddit;
pip install -r requirements.txt
  • Due to sensitive configuration information, I have hidden my personal config.py file in the gitignore. But, I have provided a clean and easy to use config template in this repo named app_config.py.

  • Fill out the flask_reddit/app_config.py file with your own information and then rename it to config.py so flask recognizes it by using mv app_config.py config.py. Please be sure to fill out the mysql db settings similarly to how you set it up!, username, pass, etc

  • Run the kickstart.py script to build the first user and subreddits.

python2.7 kickstart.py

  • flask_reddit has tasks which must occur on regular time intervals. To make this happen, we use the crontab, which is present on UNIX systems.

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.

  • Paste the contents of jobs.cron into your crontab by running crontab -e and pasting! More directions are present in the jobs.cron file.

  • Run the gunicorn server. You won't have to do this ever again if supervisor is set up properly.

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.

More Repositories

1

newspaper

newspaper3k is a news, full-text, and article metadata extraction in Python 3. Advanced docs:
Python
14,004
star
2

cracking-the-da-vinci-code-with-google-interview-problems-and-nlp-in-python

A guide on how to crack combinatorics puzzles shown in The Da Vinci Code movie using CS fundamentals and NLP
Python
83
star
3

shorten.tv

Python video summarization. Visit the public API at -- www.shorten.tv (EDIT: The domain expired and youtube blocked it ..)
Python
81
star
4

yelpcrawl

Crawl and scrape Yelp's restaurant data for every zip code in the United States (or a specified zipcode). Yelp Crawler.
Python
53
star
5

easycomplete

A python autocompletion library. Easycomplete has a simple API and utilizes google's autocomplete results & the english dictionary for now.
Python
40
star
6

newspaper-demo

Demo of the Newspaper article extraction library.
CSS
29
star
7

vsummarize

[OUT OF DATE] I only made this repo public since I'm out of Github credit, don't use it.
Python
20
star
8

puzzles

Gotta stay sharp! Common algorithms and puzzles implemented in C, Java, and Python.
Java
15
star
9

facebook-context

Facebook SoCal regional hackathon 1st place winner -- Generates real time images from text in facebook statuses.
14
star
10

antchatter

I've lost all interest in this project .. it may never be finished :(
JavaScript
7
star
11

socialrank

Pennapps '13 submission, a content aggregator
Python
6
star
12

asyncio_experiments

This code helps us understand the relationship between the # of HTTP asyncio range requests to download latency. (I was bored and wanted to play with python3.5+'s new features)
Python
5
star
13

uci-web-extraction-workshop

Sample code for a web dev workshop i'm hosting at the University of California, Irvine. It will be next week so be sure to come if you are in SoCal!
Python
4
star
14

hackuci.com

The website for UCI's first ever hackathon! Instructions are below.
CSS
4
star
15

dotfiles

Supreme terminal configurations πŸ’»
Shell
3
star
16

codestar

Website to host a software tutoring service provided by Jason Tanner and myself. We will try to implement live video and secure payments into the webapp.
CSS
3
star
17

wintria.com

Code powering my oldschool startup-website-thingy from college: www.wintria.com
CSS
2
star
18

islandoverlord

This is a Sims-eque game where the user plays as a "god" or "ruler" of a self sustaining island. No external libraries were used. Play the game at:
Java
1
star