/weather-project-app

School project: an website that you have to register and check the weather. I have used: flask, sql-alchemy db, API call, converting units form Celsius to Fahrenheit, HTML, CSS, Jinja.

Primary LanguagePython

Weather application with user authentication in Flask

Quick description:

This application will display a web page with user authentication by default, then check the weather for your desired location and measurements in Celsius or Fahrenheit degrees.

Tools

  • Backend: python with API and database
  • OpenWeatherMap API make the data collection
  • SQLAlchemy stores the data for API queries and users registration
  • Flask used for web application
  • Front-End: HTML/CSS/Jinja

Functionality

Attention: the virtual enviroment is already created for windows. If you want a fresh install delete myprojectenv directory and start from step 1.1 and skip 1.2 if you are on windows. For Linux machine skip step 1.1 and go on 1.2.

1.1 Deploy virtual environment Windows.

$ py -m venv myprojectenv
$ .\myprojectenv\Scripts\activate 
$ easy_install -U pip

1.2 Deploy virtual environment Linux.

$ sudo apt update
$ sudo apt install python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools
$ python3.7 -m venv myprojectenv
$ source myprojectenv/bin/activate
  1. Install requirements
$ pip install wheel
$ python3 -m pip install -r requirements.txt (linux)
$ py -m pip install -r requirements.txt (windows)
  1. Create configuration
$ cd project
$ nano config.py

Fill secret_key with an API key from https://openweathermap.org/current. Also add desired measurements in units as metric or imperial

>>>press ctrl+x, choose 'yes', hit enter
$ python3 config.py
  1. Create database
$ python3
>>> from project import db, create_app
>>> db.create_all(app=create_app())
>>> exit()
  1. Run server$ python3 wsgi.py
  2. You need to register or log in to website
  3. Check the weather by switching from Celsius to Fahrenheit temperature and adding/deleting cities.

* for deployment on server you will need NGINX, gunicorn and a SSL certificate. Also set debug=False in wsgi.py.