GithubHelp home page GithubHelp logo

weathersim's Introduction

CloudyWeather

Welcome to the WeatherSim!
This program will simulate a weather database and server in which for you to retrieve data from. Our main goal is to demonstrate basic socket programming with UDP and TCP.


Where to find the files for the assignment

For the MVP:

weather_station_data_sender.py  # Using UDP socket 
server.py                       # Using UDP socket 
client_server.py                # Using TCP socket
weather_app_client.py           # Using TCP socket

The extra features:

A beatiful website
Flask REST api
Docker

Installation

Configuration

With Python 3.8+

To install requirements/dependencies:

$ pip install -r requirements.txt  # or
$ pip3 install -r requirements.txt

Production

Automatically with Docker

For a very quick and easy deploy of your app we recommend hosting the app as a Docker multi-container and running that. It is fairly straight forward:

$ sudo docker-compose up -d && sudo docker attach user_client

Press Return after you have run the command above, and you should be greeted with the message:

### WeatherAPP 2.0 ###
WebApp running on http://0.0.0.0:5000/
Press 'help' for Commands | press Enter to exit 

If changes to the project are made you can redeploy with:

$ sudo docker-compose up -d --build --force-recreate && sudo docker attach user_client

This will force Docker to use the newly edited files for the images that is run in the containers

Manually

For manually deploying you need to run these python scripts simultaneous in their specific folders:

$ python client_server.py                # /server
$ python server.pu                       # /server
$ python weather_station_data_sender.py  # /station
$ python app.py                          # /server/webapp
$ python weather_app_client.py           # /client

NOTE: We highly recommend you to use Docker instead of the manual approach.

Usage

We have three ways of interacting with the app, a shell WeatherAppClient, Website, and REST api.

How to use the shell/CLI

TheWeatherAppClient is a command line program.
You can use it to view the weather data that has been generated

To see possible commands, type:

$ WAclient> help

To receive all data since the simulation start, type:

$ WAclient> get data all

You can also use the flask app we made to view the data in a browser

About

Data will be periodically generated from station.py. weather_station_data_sender.py then transmits the data by UDP to server.py which stores it to data.json. This data can then get read from client_server.py with TCP by the command line program weather_app_client.py. The flask webapp will be able to read the data from the data.json and renders an index.html webpage with data from the last 24h in a graph and last readings in big bold letters. The webapp also has an REST API that allows for specific get request over HTTP.

Illustrated model

WeatherModel

REST API Documentation

We use REST API Documentation Tool | Swagger UI for documenting of the REST API. Swagger UI allows visualizing and interact with the API's resources.

RestApi

Known bugs

data.json will eventually get very big, limiting the whole god-damn operation.

docker_entrypoint.sh may be changed by Git automatically to have a CLRF ending on Windows machine if this option is enabled in your local Git. When docker_entrypoint.sh has End of line sequence set as CLRF the docker compose up command will fail to launch the server, and you will get a error that may look like standard_init_linux.go:219: exec user process caused: no such file or directory. The fix is either no not use Windows EOL symbols or change just docker_entrypoint.sh EOL to have Unix-style EOL LF.


Participants:

Students:
Ståle Jacobsen the tech lead
Erlend Haugen the bug killer
Kim Andre Grønstøl the web maestro
Martin Eide the composer
Henrik Eide the architect

TI's:
🇷🇸Lenanomous
Sedrick Varnes

CopyRight

cartoon png from pngtree.com

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.