# Path: solarpi/weather/models.py
# class Weather(SurrogatePK, Model):
#     __tablename__ = "weather_data"
# 
#     id = Column(db.Integer(), nullable=False, primary_key=True)
#     created_at = Column(db.Text(), nullable=False, default=dt.datetime.utcnow)
#     temp = Column(db.Float(), nullable=True)
#     pressure = Column(db.Integer(), nullable=True)
#     temp_min = Column(db.Float(), nullable=True)
#     temp_max = Column(db.Float(), nullable=True)
#     humidity = Column(db.Integer(), nullable=True)
#     wind_speed = Column(db.Float(), nullable=True)
#     wind_gust = Column(db.Float(), nullable=True)
#     wind_deg = Column(db.Integer(), nullable=True)
#     clouds = Column(db.Integer(), nullable=True)
#     rain = Column(db.Integer(), nullable=True)
#     snow = Column(db.Integer(), nullable=True)
#     weather_id = Column(db.Integer(), nullable=True)


import calendar
from datetime import datetime, timedelta
from flask import Blueprint, render_template
from solarpi.weather.models import Weather



blueprint = Blueprint("weather", __name__, url_prefix="/weather", static_folder="../static")


@blueprint.route("/daily")
@blueprint.route("/daily/<date>")
def daily(date=datetime.now().strftime("%Y-%m-%d")):
    try:
        current_date = datetime.strptime(date, "%Y-%m-%d")
    except ValueError:
        current_date = datetime.strptime("2014-04-21", "%Y-%m-%d")
    yesterday = current_date - timedelta(days=1)
    tomorrow = current_date + timedelta(days=1)
    w = (

# Path: solarpi/weather/models.py
# class Weather(SurrogatePK, Model):
#     __tablename__ = "weather_data"
# 
#     id = Column(db.Integer(), nullable=False, primary_key=True)
#     created_at = Column(db.Text(), nullable=False, default=dt.datetime.utcnow)
#     temp = Column(db.Float(), nullable=True)
#     pressure = Column(db.Integer(), nullable=True)
#     temp_min = Column(db.Float(), nullable=True)
#     temp_max = Column(db.Float(), nullable=True)
#     humidity = Column(db.Integer(), nullable=True)
#     wind_speed = Column(db.Float(), nullable=True)
#     wind_gust = Column(db.Float(), nullable=True)
#     wind_deg = Column(db.Integer(), nullable=True)
#     clouds = Column(db.Integer(), nullable=True)
#     rain = Column(db.Integer(), nullable=True)
#     snow = Column(db.Integer(), nullable=True)
#     weather_id = Column(db.Integer(), nullable=True)


# Path: solarpi/weather/views.py
import calendar
from datetime import datetime, timedelta
from flask import Blueprint, render_template
from solarpi.weather.models import Weather




blueprint = Blueprint("weather", __name__, url_prefix="/weather", static_folder="../static")


@blueprint.route("/daily")
@blueprint.route("/daily/<date>")
def daily(date=datetime.now().strftime("%Y-%m-%d")):
    try:
        current_date = datetime.strptime(date, "%Y-%m-%d")
    except ValueError:
        current_date = datetime.strptime("2014-04-21", "%Y-%m-%d")
    yesterday = current_date - timedelta(days=1)
    tomorrow = current_date + timedelta(days=1)
    w = (

        Weather.query.with_entities(Weather.created_at, Weather.temp)