This app was created on top of python-getting-started. The readme for the original infrastructure is below.
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']
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 /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.
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)
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.
Make sure you have Python installed properly. Also, install the Heroku Toolbelt and Postgres.
$ git clone [email protected]: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.
$ heroku create
$ git push heroku master
$ heroku run python manage.py migrate
$ heroku open
or
For more information about using Python on Heroku, see these Dev Center articles:
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
pip install -r requirements.txt
python manage.py collectstatic
yes
[Switch to local machine]
- Kayla Iacovino - github
- David C. Rynearson
This project is licensed under the MIT License - see the LICENSE.md file for details