Skip to content

vaylon-fernandes/weather-card

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

weather-card

A weather card built using bootstrap and flask deployed on heroku

App image

Demo

See a live version deployed on heroku here

Run Locally

Clone the project

  git clone https://github.com/vaylon-fernandes/weather-card.git

Go to the project directory

  cd flask_weather_app

Create a virtual enviroment. Read more

  venv <environment name>

Note: Linux user might have to install venv using the following command

   apt-get install python3-venv

Activate the virtual environment

On Linux:

source venv/bin/activate

On Windows:

venv\Scripts\activate

Install dependencies

  pip install -r requirements.txt

In addition to the dependancies you wil have to create a Open Weather Map and get a API Key. Read about how to get a 'API Key' in the open weather mao FAQ section here

Configuring environment Variables

  • Firstly Generate a Secret Key. This is required by the Flask Sessions. Do read the section on How to generate good secret keys in the flask documentation under sessions here
  • Next export the secret key and API key to Enviroment Variables using one of the following commands based on your terminal Bash command
  export SECRET_KEY=<your secret key>
  export API_KEY=<your API key>

CMD command

  set SECRET_KEY=<your secret key>
  set API_KEY=<your API key>

Powershell command

  $env:SECRET_KEY=<your secret key>
  $env:API_KEY=<your API key>

The enviroment variables are then read using the os.getenv object

Running the app

To run the app, first export the FLASK_APP variable, using one of the following commands based on your terminal
Bash command

  export FLASK_APP=main

CMD command

  set FLASK_APP=main

Powershell command

  $env:FLASK_APP = "main"

Run command

flask run

This creates a simple server, go to http://127.0.0.1:5000/ in your browser to view the site

Debug mode

To run the server in Debug mode, export the FLAK_ENV variable befor running flask run Bash command

  export FLASK_ENV=development

CMD command

  set FLASK_ENV=development

Powershell command

  $env:FLASK_ENV="development"

Run command

flask run

Read more here: https://flask.palletsprojects.com/en/2.0.x/quickstart/#debug-mode

Deploying to Heroku

  • There's a good explanation of this given in this repo
  • Another good read on the topic is on the Real Python website

References

Resources

About

A weather card built using bootstrap and flask deployed on heroku

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published