GithubHelp home page GithubHelp logo

herokuspy's Introduction

herokuspy

I present this repository, herokuspy, to the Python Meetup 2016-01-18:

http://www.meetup.com/BayPIGgies/events/227481217

The herokuspy repository depends on the pyspy repository.

I always install pyspy before I install herokuspy.

It is easy to install pyspy, the repository is at this URL:

https://github.com/danbikle/pyspy

The herokuspy repository is an enhancement of the repository listed below:

https://github.com/heroku/python-getting-started

I like to install herokuspy into this folder:

/home/ann/herokuspy

You could try to install it elsewhere.

Anyway, I do this:

cd ~
git clone https://github.com/danbikle/herokuspy

Next, I install the Heroku Toolbelt:

cd ~
rm -rf heroku-client.tgz heroku-client
wget https://s3.amazonaws.com/assets.heroku.com/heroku-client/heroku-client.tgz
tar zxf heroku-client.tgz
echo 'export PATH=/home/ann/heroku-client/bin:${PATH}' >> ~/.bashrc
bash

Then, I create an ssh-key for ann account (assuming ann has none yet).

ssh-keygen -t rsa

Next, I navigate to heroku.com and create an account via the web-ui.

Then, I return to the shell and give copy of ann public ssh-key to heroku:

cd ~/herokuspy
~/heroku-client/bin/heroku status
~/heroku-client/bin/heroku auth:login
~/heroku-client/bin/heroku auth:whoami
~/heroku-client/bin/heroku keys:add

Also, in my local Ubuntu host, I create an ann account in Postgres:

cd ~/herokuspy
sudo su - postgres
psql
CREATE ROLE ann WITH superuser login;
CREATE DATABASE ann;
\q
exit

At this point I should be able to create an app on heroku:

cd ~/herokuspy
~/heroku-client/bin/heroku create hspy10

You will need to use a different app name than hspy10.

Perhaps hspy11 is available?

I use git to deploy the app to heroku:

git push heroku master
~/heroku-client/bin/heroku run python manage.py migrate

I should be able to see my app with a browser:

https://hspy10.herokuapp.com/

If I can see my app run on heroku, I should try to run it locally in my Ubuntu host.

I start this effort by running some shell commands:

cd ~/herokuspy
~/anaconda3/bin/pip install -r requirements.txt
/usr/bin/createdb python_getting_started
~/heroku-client/bin/heroku local:run python manage.py migrate
python manage.py collectstatic
~/heroku-client/bin/heroku local

My app should now be accepting requests at this URL:

http://localhost:5000

Operation

I operate herokuspy in two different modes.

First, I run a script at 12:50pm Mon-Fri California time which relies on pyspy to observe the current price of the S&P 500 index.

Next, the script uses this new observation to generate the most recent prediction.

This prediction is published to the web so that users can act on it before the market closes at 13:00pm (16:00 NY time).

The script is listed below:

~/herokuspy/bin/noon50.bash

In the second mode I run a script at 21:00pm Mon-Fri California time which uses the closing price of the S&P 500 index to generate the most recent prediction.

This second script is listed below:

~/herokuspy/bin/night.bash

The content below was written by the developers at Heroku:


python-getting-started

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

This application support 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 [email protected]:heroku/python-getting-started.git
$ cd python-getting-started
$ pip install -r requirements.txt
$ createdb python_getting_started
$ heroku local:run 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:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.