Help printing sensor data to server

Hi, im making a program that sends the values from my DFRobot heartrate sensor into a webpage in a local server, my problem is that i can't print out the values from the heartrate sensor, i keep seeing 0 on my webpage. It functions okay when i upload the sample program that comes with it. But I need to print it on a webpage.

#define heartratePin A0
#include "DFRobot_Heartrate.h"
#include <ESP8266WiFi.h>

// Replace with your network credentials
const char* ssid     = "ZTE_2.4G_KpUtMH";
const char* password = "64bqq3EC";

// Set web server port number to 80
WiFiServer server(80);

DFRobot_Heartrate heartrate(DIGITAL_MODE); ///< ANALOG_MODE or DIGITAL_MODE

void setup() {
  Serial.begin(115200);

  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  // Print local IP address and start web server
  Serial.println("");
  Serial.println("WiFi connected.");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  server.begin();

}

void loop() {
   WiFiClient client = server.available();
  if (!client) {
    return;
  }
   // Listen for incoming clients


// Wait until the client sends some data
  Serial.println("new client");
  while(!client.available()){
    delay(1);
  }

  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();

  uint8_t rateValue;
  heartrate.getValue(heartratePin); ///< A1 foot sampled values
  rateValue = heartrate.getRate(); ///< Get heart rate value 
  if(rateValue)  {
    Serial.println(rateValue);
  }
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println("Refresh: 1");
  client.println("");
  client.println("<!DOCTYPE HTML>");
  client.println("<html>");
  client.println("<head>");
  client.println("<title>");
  client.println("RSSI Measuring");
  client.println("</title>");
  client.println("</head>");
  client.println("<center>");
  client.println("<h1>");
  client.println("</h1>");
  client.print(rateValue);
  client.println("<p>========================================</p>");
  client.println("<p>========================================</p>");
  client.println("</center>");
  client.println("</html>");
  delay(20);
}

This is the code that comes with the Sensor Library for reference

#define heartratePin A1
#include "DFRobot_Heartrate.h"

DFRobot_Heartrate heartrate(DIGITAL_MODE); ///< ANALOG_MODE or DIGITAL_MODE

void setup() {
  Serial.begin(115200);
}

void loop() {
  uint8_t rateValue;
  heartrate.getValue(heartratePin); ///< A1 foot sampled values
  rateValue = heartrate.getRate(); ///< Get heart rate value 
  if(rateValue)  {
    Serial.println(rateValue);
  }
  delay(20);
}