Coder Social home page Coder Social logo

iq-scm / heroku-python-script Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michaelkryukov/heroku-python-script

0.0 0.0 0.0 57 KB

Guide for hosting python scripts and applications on Heroku

License: MIT License

Python 71.91% Procfile 28.09%

heroku-python-script's Introduction

Template for hosting python scripts and applications on Heroku

This is a small example of running your script with Heroku. You can run almost any python application with any dependencies.

Getting Started

  1. Download or clone this repository

  2. Register on Heroku

  3. Download and install Heroku CLI

  4. Download and install git

  5. Copy your script or project to this repository's folder

  6. Replace "script.py" with the path to your main executable file in Procfile. For details about Procfile refer to the docs. If you need to run web application, you have to use web instead of worker.

  7. You may select your python version and runtime using runtime.txt. Read how on official heroku page.

  8. If you are using any not built-in modules, you must add them to your requirements.txt. To check which version of the module you have, run pip freeze in the terminal. You will get lines with information about installed modules and their versions in the format like MODULE_NAME==MODULE_VERSION. Add lines with required modules and their versions to your requirements.txt. Heroku will install modules from this file automatically.

    If you are using some kind of virtual environment, you can generate ready-to-use requirements.txt with pip freeze > requirements.txt.

  9. Open terminal (or do it another way, but I will explain how to do it in the terminal on Ubuntu) and create a git repository.

    1. Initiate git repository

      git init
    2. Create heroku application

      heroku create
    3. Add, commit and push your code into branch master of the remote heroku.

      git add .
      git commit -m "initial commit"
      git push heroku master
  10. Specify the amount of worker that will run your application

    heroku ps:scale worker=1
  11. Now everything should be working. You can check your logs with this command

    heroku logs --tail
  12. You can open the URL where the script is deployed using the below command (if you are deploying web application)

    heroku open
  13. From now on you can use usual git commands (push, add, commit, etc.) to update your app. Every time you push heroku master your app gets redeployed with updated source code

  14. To stop your application scale down the amount of workers with like this

    heroku ps:scale worker=0

Prerequisites

Authors

Acknowledgments

heroku-python-script's People

Contributors

archanaprabhu avatar josephwegner avatar michaelkryukov avatar

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.