A website that uses machine learning to predict the weather.
- Flask web server for Debian/Ubuntu
- Login and signup page
- Cookie usage when user logs in
- Database for user login credentials
- Password hashing
- Random Forest Classifier model that takes user's inputs and predicts weather
To create a quick-and-dirty server, follow these instructions:
- Install Python and pip
- pip install -r requirements.txt
- Run the shell script
- Go to 127.0.0.1:5000 for localhost or the private IP address of the server in a browser
To create a server the proper way, follow these instructions:
- Install Python 3.10.4, pip, and venv. Pyenv is preferred for this.
apt install nginx git
git clone https://github.com/WillChamness/WeatherPredictionSystem && cd WeatherPredictionSystem
python -m venv env
andsource env/bin/activate
- Install
gunicorn
with pip or apt. Pip is preferred and will be assumed for the gunicorn config. pip install -r requirements.txt
- Change the last line in
app.py
toapp.run(host='0.0.0.0', debug=False)
- Use the Nginx configuration below
- Use the gunicorn daemon configuration below
- Go to the IP address of the server in a browser
Create /etc/nginx/sites-enabled/flask-app
and add the following:
server {
listen 80 default_server;
location / {
proxy_pass http://127.0.0.1:8000; # port number not a typo
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Then unlink the default config and test the syntax:
sudo unlink /etc/nginx/sites-enabled/default
sudo nginx -t
If there are no errors, reload Nginx:
sudo nginx -s reload
Create /etc/systemd/system/weather-prediction.service
and add the following:
[Unit]
Description=Flask App
[Service]
Type=simple
ExecStart=/path/to/WeatherPredictionSystem/env/bin/gunicorn --chdir /path/to/WeatherPredictionSystem/ app:app
[Install]
WantedBy=multi-user.target
Then start and check the service:
sudo systemctl start weather-prediction
sudo systemctl status weather-prediction
If there are no errors, enable the service:
sudo systemctl enable weather-prediction