text: # ---------------------------------------------------- #
  # Import packages
  # ---------------------------------------------------- #
  import Adafruit_DHT
  import RPi.GPIO as GPIO
  
  # ---------------------------------------------------- #
  # Import packages
  # ---------------------------------------------------- #
  from fastapi import FastAPI
  
  
  # ---------------------------------------------------- #
  # Initialize API
  # ---------------------------------------------------- #
  app = FastAPI()
  
  
  # ---------------------------------------------------- #
  # Initialize temperature and humidity reader
  # ---------------------------------------------------- #
  sensor = Adafruit_DHT.DHT11
  
  
  # ---------------------------------------------------- #
  # GPIO pins
  # ---------------------------------------------------- #
  sensor_outside_pin = 2
  sensor_inside_pin = 3
  light_pin = 13
  motor_a_pin = 16
  motor_b_pin = 18
  motor_enabled_pin = 22
  
  
  # ---------------------------------------------------- #
  # GPIO settings
  # ---------------------------------------------------- #
  GPIO.setmode(GPIO.BOARD)
  GPIO.setwarnings(False)
  
  
  # ---------------------------------------------------- #
  # GPIO setup
  # ---------------------------------------------------- #
  GPIO.setup(light_pin,GPIO.IN)
  GPIO.setup(motor_a_pin,GPIO.OUT)
  GPIO.setup(motor_b_pin,GPIO.OUT)
  GPIO.setup(motor_enabled_pin,GPIO.OUT)
  
  
  # ---------------------------------------------------- #
  # Get root data
  # ---------------------------------------------------- #
  @app.get("/")
  async def root():
      return {"Hello": "Greenhouse"}
  
  
  # ---------------------------------------------------- #
  # Get greenhouse data
  # ---------------------------------------------------- #
  @app.get("/greenhouse-data", tags=["Greenhouse-Data"])
  async def read_sensors():
      """Returns the sensor values"""
      try:
          humidity_inside_raw, temperature_inside_raw = Adafruit_DHT.read_retry(sensor, sensor_inside_pin)
          humidity_outside_raw, temperature_outside_raw = Adafruit_DHT.read_retry(sensor, sensor_outside_pin)
  
          light_sufficient = True
          if GPIO.input(light_pin):
              light_sufficient = False
  
          ventilator_running = True
          if GPIO.input(motor_a_pin):
              ventilator_running = False
  
          return {"success"            : True                   ,
                  "light_sufficient"   : light_sufficient       ,
                  "ventilator_on"      : ventilator_running     ,
                  "humidity_inside"    : humidity_inside_raw    ,
                  "temperature_inside" : temperature_inside_raw ,
                  "humidity_outside"   : humidity_outside_raw   ,
                  "temperature_outside": temperature_outside_raw}
  
      except:
          return {"succes": False}
  
  
  # ---------------------------------------------------- #
  # Turn on ventilator
  # ---------------------------------------------------- #
  @app.get("/ventilator-on", tags=["Greenhouse-Mechanic"])
  async def ventilator_on():
      """Turns on the ventilator"""
      try:
          GPIO.output(motor_enabled_pin,GPIO.HIGH)
          GPIO.output(motor_a_pin,GPIO.LOW)
          GPIO.output(motor_b_pin,GPIO.HIGH)
  
          return {"succes": True}
      except:
          return {"succes": False}
  
  
  # ---------------------------------------------------- #
  # Turn off ventilator
  # ---------------------------------------------------- #
  @app.get("/ventilator-off", tags=["Greenhouse-Mechanic"])
  async def ventilator_off():
      """Turns off the ventilator"""
      try:
          GPIO.output(motor_a_pin,GPIO.HIGH)
  
          return {"succes": True}
      except:
          return {"succes": False}