GithubHelp home page GithubHelp logo

m0nica / flask_weather Goto Github PK

View Code? Open in Web Editor NEW
87.0 3.0 82.0 455 KB

☀️ ☔️ Flask app to auto-detect local weather based off of user's IP address.

Home Page: https://clima-weather.herokuapp.com/

Python 59.65% HTML 40.35%
weather flask ip detection python hacktoberfest

flask_weather's Introduction

Flask Weather App ☀️☔️

This is a Flask (Python) application that auto-detects local weather based off of user's external IP address.

Example screenshot of flask_weather application

Setup

  • Install dependencies
  • pip install -r requirements.txt
  • Add environment variables
    • weather_key="###############";. The weather_key is the API key received from registering at https://darksky.net/dev.
    • add secret_key="********". It should be a random string that is hard to guess.
  • Run
    • python app.py
  • Run Tests
    • python flask_weather_tests.py

Functionality

Gets a user's external IP address and then used http://freegeoip.net to get more specific location information to pass into Weather API (https://darksky.net/dev/). Weather information (current temperature and % chance of rain) is returned based on the location associated with the IP.

To work on this locally clone the repo, request and add an API key (locally) from darksky and then run app.py

weather.html displays the weather information and displays appropriate weather icon (https://erikflowers.github.io/weather-icons/) based on what the current weather is.

To display temperature in Celsius instead of Fahrenheit, set celsius = True environment variables.

Sample Output:

Today's Weather Forecast for Brooklyn, New York

Right now it is 41° and there is a 0% chance of rain.

Today's Weather Forecast for City, State

Right now it is X° and there is a Y% chance of rain.

flask_weather's People

Contributors

abhiagarwal192 avatar blitzh0t avatar byarmis avatar dillionverma avatar jcyktor avatar joviij avatar m0nica avatar ming060 avatar mtenmann avatar psyonara avatar tekknolagi avatar tmarthal avatar vayupranaditya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flask_weather's Issues

[Request] Ability to manually enter a location

  • Add in a location drop down or another form validation way that would prevent people from including inaccurate locations

  • Allow strings (non-IP addresses) to translate into latitude and longitude for the weather API

  • Short-term fix could be to include weather for major cities

Add Travis CI

Add Travis CI integration to ensure tests have passed for all PRs

[DISCUSSION] Renaming App

I am planning on having this app hosted on Heroku or Digital Ocean #29

However, I think the app needs a new name off of Github (and additional branding i.e., header once a name is decided).

Does anyone have thoughts as to what the name could be?

In terms of development work, there will be follow up tasks to update the website (once a name is determined)

  • adding name to header
  • adding name to title
  • adding name to footer
  • updating documentation as needed
    ...etc.

Add background image

The current background image is plain -- could it be spruced up to reflect the actual weather? clouds floating in the background? or just look nicer in general?

This is an open-ended issue and creativity is welcome.

screenshot of the flask weather app

Add umbrella emoji

Add umbrella emoji whenever umbrellas are mentioned in the commentary

Example:

it is definitely going to rain today! GRAB YOUR UMBRELLA. ☔

Don't Display LAT, LON in URL

Current route format: http://localhost:5000/weather/{LAT, LON}/{CITY}/{STATE}

Instead of displaying LAT, LON in the URL the URL should conceal LAT LON and appear as
http://localhost:5000/weather/{CITY}/{STATE}

city/state route breaks when session cookie is removed

If I go to https://clima-weather.herokuapp.com/

it redirects to https://clima-weather.herokuapp.com/weather/New%20York/New%20York
(https://clima-weather.herokuapp.com/weather/{city}/{state})

if I delete my session cookie this url returns a 500 error:
https://clima-weather.herokuapp.com/weather/New%20York/New%20York
(https://clima-weather.herokuapp.com/weather/{city}/{state})

Steps to reproduce:

  • go to the app
  • delete session cookie
  • refresh page (and 500 error appears)

Desired functionality:

Allow users to navigate to city/state route regardless of their ip address/location

Add Weather Commentary [Submit copy!]

Currently, we display rain_commentary based on the RAIN_WARNING. It would be great if additional commentary was added to look at RAIN_WARNING, temperature and maybe weather_icon.

Creative but relevant copy enhancements are welcome! This is something that multiple people can contribute to.

Also at some point, it could be implemented so that the message varies when you refresh the page with another relevant piece of commentary for the same weather report.

     rain_commentary = "there is a no chance of rain! It's a sunny day"
 elif 0 < RAIN_WARNING <= .5:
     rain_commentary = "there is a slight chance of rain. You might want to grab an umbrella"
 elif  .5 < RAIN_WARNING <.75:
     rain_commentary = "there is a high chance of rain. Grab an umbrella on your way out!"
 elif  RAIN_WARNING == 1:
     rain_commentary = "it is raining right now!"
 else:
     rain_commentary = "it is definitely going to rain today! GRAB YOUR UMBRELLA."

Allow users to manually choose another city

  • If you visit website and then go to a new city the session cookie may still be present (if you haven't closed browser) and will display weather information for previous city
  • add a link for someone to click on if they want to see the weather in another city i.e. (Want to see the weather for another city?)
  • when the user clicks they should be able to change the city -- you can decide what type of UI to use to allow user to choose a different city

Update Color of Icon (or add emojis) To Reflect Weather

We display weather icons with the weather. Some enhancements could be made to change the color of the icon to correlate with the weather (sunny i.e., orange/yellow; rain blue; snow/sleet, etc. grey).

OR display emojis instead of current weather icons

Note the types of icon text values that our current weather API returns

A machine-readable text summary of this data point, suitable for selecting an icon for display. If defined, this property will have one of the following values: clear-day, clear-night, rain, snow, sleet, wind, fog, cloudy, partly-cloudy-day, or partly-cloudy-night. (Developers should ensure that a sensible default is defined, as additional values, such as hail, thunderstorm, or tornado, may be defined in the future.)

We currently handle the following:

   <i class="wi wi-day-sunny"></i>
{% elif weather_icon == "clear-night"%}
   <i class="wi wi-night-clear"></i>
{% elif weather_icon == "rain"%}
    <i class="wi wi-rain"></i>
{% elif weather_icon == "snow"%}
    <i class="wi wi-snow"></i>
{% elif weather_icon == "sleet"%}
    <i class="wi wi-sleet"></i>
{% elif weather_icon == "wind"%}
    <i class="wi wi-wind"></i>
{% elif weather_icon == "fog"%}
    <i class="wi wi-fog"></i>
{% elif weather_icon == "cloudy"%}
    <i class="wi wi-cloudy"></i>
{% elif weather_icon == "partly-cloudy-day"%}
    <i class="wi wi-forecast-io-partly-cloudy-day"></i>
{% elif weather_icon == "partly-cloudy-day"%}
    <i class="wi wi-forecast-io-partly-cloudy-day"></i>
{% else %}
    <i class="wi wi-day-sunny"></i>

 {% endif %}

screenshot of the flask weather app

Display temperature unit °C or °F

Display °C or °F after temperature depending on which unit is being used.

View this PR for more context about how temperature units are currently being used in the app:

#32

Fix 404 Page Routing

@joviij #7 implemented a 404 page. However, it seems that is not displaying as expecting (At least for me). It would be great if someone could investigate and fix if needed.

Detects Server IP instead of Client IP

Need to figure out how to detect Client IP in Flask application without using request. Want the app to behave the same aside from this small but MAJOR change!

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.