text: from flask import Flask, jsonify
  import datetime as dt
  
  import sqlalchemy
  from sqlalchemy.ext.automap import automap_base
  from sqlalchemy.orm import Session
  from sqlalchemy import create_engine, func
  
  #set the database
  engine = create_engine("sqlite:///hawaii.sqlite")
  Base = automap_base()
  Base.prepare(engine, reflect=True)
  
  # Base.metadata.tables 
  
  Measurement = Base.classes.measurement
  Station = Base.classes.station
  
  #flask setup
  app = Flask(__name__)
  #all route
  
  @app.route("/")
  def Hello():
      """List all available api routes."""
      return (
          f"Available Routes:<br/>"
          f"Precipitation: /api/v1.0/precipitation<br/>"
          f"List of Stations: /api/v1.0/stations<br/>"
          f"Temperature for one year: /api/v1.0/tobs<br/>"
          f"Temperature stat from the start date(yyyy-mm-dd): /api/v1.0/yyyy-mm-dd<br/>"
          f"Temperature stat from start to end dates(yyyy-mm-dd): /api/v1.0/yyyy-mm-dd/yyyy-mm-dd"
      )
  
  @app.route('/api/v1.0/<start>')
  def get_t_start(start):
      session = Session(engine)
      result = session.query(func.min(Measurement.tobs), func.avg(Measurement.tobs), func.max(Measurement.tobs)).\
          filter(Measurement.date >= start).all()
      session.close()
  
      tobsall = []
      for min,avg,max in result:
          tobs_dict = {}
          tobs_dict["Min"] = min
          tobs_dict["Average"] = avg
          tobs_dict["Max"] = max
          tobsall.append(tobs_dict)
  
      return jsonify(tobsall)
  
  @app.route('/api/v1.0/<start>/<stop>')
  def start_stop(start,stop):
      session = Session(engine)
      result = session.query(func.min(Measurement.tobs), func.avg(Measurement.tobs), func.max(Measurement.tobs)).\
          filter(Measurement.date >= start).filter(Measurement.date <= stop).all()
      session.close()
  
      tobsall = []
      for min,avg,max in result:
          tobs_dict = {}
          tobs_dict["Min"] = min
          tobs_dict["Average"] = avg
          tobs_dict["Max"] = max
          tobsall.append(tobs_dict)
  
      return jsonify(tobsall)
  
  @app.route('/api/v1.0/tobs')
  def tobs():
      session = Session(engine)
      lateststr = session.query(Measurement.date).order_by(Measurement.date.desc()).first()[0]
      latestdate = dt.datetime.strptime(lateststr, '%Y-%m-%d')
      querydate = dt.date(latestdate.year -1, latestdate.month, latestdate.day)
      sel = [Measurement.date,Measurement.tobs]
      result = session.query(*sel).filter(Measurement.date >= querydate).all()
      session.close()
  
      tobsall = []
      for date, tobs in queryresult:
          tobs_dict = {}
          tobs_dict["Date"] = date
          tobs_dict["Tobs"] = tobs
          tobsall.append(tobs_dict)
  
      return jsonify(tobsall)
  
  @app.route('/api/v1.0/stations')
  def stations():
      session = Session(engine)
      sel = [Station.station,Station.name,Station.latitude,Station.longitude,Station.elevation]
      result = session.query(*sel).all()
      session.close()
  
      stations = []
      for station,name,lat,lon,el in queryresult:
          station_dict = {}
          station_dict["Station"] = station
          station_dict["Name"] = name
          station_dict["Lat"] = lat
          station_dict["Lon"] = lon
          station_dict["Elevation"] = el
          stations.append(station_dict)
  
      return jsonify(stations)
  
  @app.route('/api/v1.0/precipitation')
  def precipitation():
      session = Session(engine)
      sel = [Measurement.date,Measurement.prcp]
      result = session.query(*sel).all()
      session.close()
  
      precipitation = []
      for date, prcp in queryresult:
          prcp_dict = {}
          prcp_dict["Date"] = date
          prcp_dict["Precipitation"] = prcp
          precipitation.append(prcp_dict)
  
      return jsonify(precipitation)
  
  if __name__ == '__main__':
      app.run(debug=True)