Setting up local development - nrjones8/plagapp GitHub Wiki

This is based in part on: http://net.tutsplus.com/tutorials/python-tutorials/an-introduction-to-pythons-flask-framework/

First, clone the repo into a new directory. Navigate to the directory above your plagcomps repo (call it HOME for now) and run: git clone https://github.com/nrjones8/plagapp.git

which will create a new directory called plagapp. So your directory structure should now look like:

  • HOME
    • plagcomps
    • plagapp

Flask uses virtual environments, which essentially creates a local copy of Python and whatever other Python packages we need to use in our app. It's a nice way to avoid having to deal with different versions of Python/other packages on different people's machines. To use it, we need to install virtualenv. If you don't have pip (one of Python's package managers, see: https://pypi.python.org/pypi/pip) installed yet, then run:

sudo easy_install pip

And now we can install virtualenv:

sudo pip install virtualenv

Navigate back to HOME (if you're not already there). We'll now set up a virtual environment for our app and then activate it:

virtualenv plagapp
cd plagapp
. bin/activate

Now we can install the packages we need for the app to run. Luckily, the necessary packages are all listed in requirements.txt! When first starting the app, you generally need to install some packages manually. Once we've figured out everything we need, this file can be created by running (but don't run it now!):

pip freeze > requirements.txt

Since requirements.txt already exists, we just need to install all the packages listed there:

pip install -r requirements.txt

If that doesn't work for some reason, try adding a sudo before pip. Now everything should be up and running! Run:

python run.py

and navigate to localhost:5000 in your browser to see the app running!

It's possible you'll get an NLTK error at this point telling you to install the nltk corpus -- follow those directions, and all should be well!