Giter Club home page Giter Club logo

Host a static website in Heroku for FREE using Python Flask framework

Guideline:

Part 1: Push your website live to Heroku

-Download [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
-Download [Heroku CLI](https://devcenter.heroku.com/articles/getting-started-with-python#set-up) (Command Line Interface)

2.Create a Heroku account

3.Create a project folder and organize the folder structure - in your Terminal / Command Line Prompt

$mkdir Website_Example

$cd Website_Example

$mkdir templates

so your folder structure will look like:

Website_Example

templates

index.html

4.Create a virtual environment and activate it

$pip install virtualenv

make a virtualenv called "venv":

$virtualenv venv

activate this virtual env:

- macOS:

    $source venv\bin\activate

- windows:

    $venv\Scripts\activate

5.Init Git in project folder

$git init

6.pip install all required dependencies:

$pip install Flask

$pip install gunicorn

7.Create a Flask app/backend

$touch index.py
from flask import Flask, render_template


app = Flask(__name__)


@app.route("/") #www.domain.com - render homepage
def index():

    return render_template("index.html")


if __name__ == "__main__":

    app.run(debug=False)

8.Create a Procfile

$touch Procfile

make sure you capitalize the first letter and name the file WITHOUT any extension. in your Procfile, include:

web: gunicorn index:app

make sure you:

  1. do NOT include any space between "index:" and "app" - "index" is the .py file where your Flask backend lives in and "app" is the variable name of the flask object that's defined in index.py file.

  2. include ONE space between "web:" and "gunicorn" -

9.Create a requirements.txt file

$pip freeze > requirements.txt

10.Push our app/website to Heroku

$heroku login

-your browser pops up asking you to log into your Heroku CLI

$heroku create

-create a new Heroku app randomly named by Heroku (you can pass a specific App name but it has to be uniquely available.)

$ git status

-track your file changes and locate the untracked files detected by git

$ git add .

-add all files to git staging area so that you can push files to Heroky in next steps

$ git commit -m"give your wished comments for app pushing"

-this is to commit all your changes

$ git push heroku master

-finally pushing your apps and files to Heroku server wait a few minutes and let Heroku do all the heavy liftings for you. After successfully deploying:

$heroku open

-open your app url and view it in your browser.

Part 2: Add a custom domain to your Heroku hosted app

  • Get a free domain

    1. Go to freenom to sign up an account
    2. Grab a free domain
  • Visit your hosted webste in Heroku

    1. Log in Heroku and go to dashboard to visit the hosted app

    2. Add custom domains in your app's setting page.

  • Add Heroku DNS CNAME records to Freenom DNS console.

    1. Head over to Freenom DNS Console

    2. Point CNMAE records to Heroku-required records

  • Await a few minutes to see your website live @ yourwebsite.com

elanozturk's Projects

botgram icon botgram

⚙️ Microframework to build Telegram bots

cool-retro-term icon cool-retro-term

A good looking terminal emulator which mimics the old cathode display...

face_classification icon face_classification

Real-time face detection and emotion/gender classification using fer2013/imdb datasets with a keras CNN model and openCV.

forever-service icon forever-service

Provision node script as a service via forever, allowing it to automatically start on boot, working across various Linux distros and OS

fpm icon fpm

Effing package management! Build packages for multiple platforms (deb, rpm, etc) with great ease and sanity.

geeksforgeeks.pdf icon geeksforgeeks.pdf

Topic wise PDFs of Geeks for Geeks articles. (Last updated in October 2018)

geo icon geo

:earth_americas: A Bash utility for easy wan, lan, router, dns, mac address, and geolocation output, with clean stdout for piping

glances icon glances

Glances an Eye on your system. A top/htop alternative.

gotty icon gotty

Share your terminal as a web application

intergram icon intergram

Free live chat widget linked to your Telegram messenger

keepcli icon keepcli

Simple and unofficial command line interface for Google Keep written in Python

mailinabox icon mailinabox

Mail-in-a-Box helps individuals take back control of their email by defining a one-click, easy-to-deploy SMTP+everything else server: a mail server in a box.

netdata icon netdata

Get control of your servers. Simple. Effective. Awesome! https://my-netdata.io/

opencv4nodejs icon opencv4nodejs

Asynchronous OpenCV 3.x nodejs bindings with JavaScript and TypeScript API, with examples for: Face Detection, Machine Learning, Deep Neural Nets, Hand Gesture Recognition, Object Tracking, Feature Matching, Image Histogram

openface icon openface

OpenFace – a state-of-the art tool intended for facial landmark detection, head pose estimation, facial action unit recognition, and eye-gaze estimation.

openpose icon openpose

OpenPose: Real-time multi-person keypoint detection library for body, face, and hands estimation

openpyn-nordvpn icon openpyn-nordvpn

Easily connect to and switch between, OpenVPN servers hosted by NordVPN. (+patch leakes)

openvpn-install icon openvpn-install

Set up your own OpenVPN server on Debian, Ubuntu, Fedora CentOS, and Arch Linux

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.