kaylai / DensityX-heroku

Heroku deployment of DensityX program

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Density-X Heroku deployment

This app was created on top of python-getting-started. The readme for the original infrastructure is below.

Test on your local.

Create a virtual environment to test the app on your local machine. If you've never created a virtual environment called 'venv' before, run:

$ conda create virtualenv -n venv

Then:

$ conda env export -n venv
$ source activate venv
$ pip install -r requirements.txt

Then run the thing...

$ python manage.py collectstatic

(answer yes)

$ heroku local web

Now access the local deployment at http://localhost:5000

If you are having issues getting this to run, your 5000 port may be busy. Kill all processes on that port with:

$ kill `lsof -i :5000`

Note if you get an error of DisallowedHost, you will need to add localhost to uploads/settings.py:

ALLOWED_HOSTS = ['someapp.herokuapp.com', 'localhost']

Push changes and deploy on Heroku.

NOTE: This app currently has webhooks setup so that you do not need to push to heroku. If pushed to github, Heroku app will automatically rebuild and redeploy. In other words, skip this step...

$ git add .
$ git commit -m "commit message"
$ git push heroku master
$ heroku open

Done forget to also push to github (here; origin master) where you should definitely also be saving these files:

$ git add .
$ git commit -m "commit message"
$ git push origin master

The file structure

The file /uploads/core/view.py is where your python code (the actual code being deployed, in this case DensityX.py) lives.

The file /uploads/templates/base.html is the base html file that is essentially your index.html file. All other html files extend base.

The file /uploads/core/templates/core/home.html is where the stuff on your index page is defined. For example, the upload button in DensityX is defined here.

Some files you'll need

Use python-getting-started from heroku for an example of a working setup with all required files (readme for original is below)

requirements.txt file - all dependencies and versions go here. To get version: run python, import module, type:

$ print module.__version__

urls.py - list of all the "pages" on the web interface

view.py - where the actual python code gets called and executed. The script to run must be wrapped as a function like:

def my_python_script(some_thing)

python-getting-started

A barebones Python app, which can easily be deployed to Heroku.

This application supports the Getting Started with Python on Heroku article - check it out.

Running Locally

Make sure you have Python installed properly. Also, install the Heroku Toolbelt and Postgres.

$ git clone git@github.com:heroku/python-getting-started.git
$ cd python-getting-started

$ pip install -r requirements.txt

$ createdb python_getting_started

$ python manage.py migrate
$ python manage.py collectstatic

$ heroku local

Your app should now be running on localhost:5000.

Deploying to Heroku

$ heroku create
$ git push heroku master

$ heroku run python manage.py migrate
$ heroku open

or

Deploy

Documentation

For more information about using Python on Heroku, see these Dev Center articles:

David's setup notes (macOS)

In local Machine

git clone https://github.com/kaylai/DensityX-heroku.git
cd DensityX-heroku
brew install postgresql
conda create virtualenv -n venv
source activate venv
[Switch to Venv Machine]
heroku local web

In Venv Machine

pip install -r requirements.txt
python manage.py collectstatic
yes
[Switch to local machine]

Authors

  • Kayla Iacovino - github
  • David C. Rynearson

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

Heroku deployment of DensityX program

License:MIT License


Languages

Language:JavaScript 59.1%Language:CSS 30.0%Language:Python 8.6%Language:HTML 2.3%Language:Procfile 0.0%