ESP8266-01 I'm getting HTML code rather than HTML rendered web page

Ok,
I'm just probably burned out on this but for some reason I'm getting Raw HTML code, rather than the page being displayed in HTML as web pages should be.

The code is below.
Note that I'm using statip IP's and the I think the author set this up for use as DHCP so his IDP line might have something to do with it?

if(wifi_module.find("+IPD,"))

Or...this line maybe?

int connectionId = wifi_module.read()-48;

Here's the full code for the sketch (using an Arduino UNO and an MQ-2 Sensor)

#include <SoftwareSerial.h>
#define DEBUG true
SoftwareSerial wifi_module(2,3); // Connect TX pin of esp to the pin 2 of Arduino and RX pin of esp to the pin 3 of Arduino


int red_led_pin = 9;
int green_led_pin = 8;
int buzzer_pin = 10;
int smoke_sensor_pin = A0;

void setup()

{

  Serial.begin(115200);
  wifi_module.begin(115200); // Set the baudrate according to your esp8266

  pinMode(red_led_pin, OUTPUT);
  pinMode(green_led_pin, OUTPUT);
  pinMode(buzzer_pin, OUTPUT);
  pinMode(smoke_sensor_pin, INPUT);

 esp8266_command("AT+RST\r\n",2000,DEBUG); // reset module
 esp8266_command("AT+CWMODE=3\r\n",1000,DEBUG); // configure as access point

  esp8266_command("AT+CIPSTA=\"192.168.003.58\",\"192.168.003.001\",\"255.255.255.000\"\r\n",10000,DEBUG);
  esp8266_command("AT+CWJAP_CUR=\"MySSID\",\"password\"\r\n",10000,DEBUG);
  
  esp8266_command("AT+CIFSR\r\n",1000,DEBUG); // get ip address
  esp8266_command("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections
  esp8266_command("AT+CIPSERVER=1,37731\r\n",1000,DEBUG); // turn on server on port

}

void loop()
{
  int analogSensor = analogRead(smoke_sensor_pin);
  
  if (analogSensor > 300)
  {
Serial.println(analogSensor);
    digitalWrite(red_led_pin, HIGH);
    digitalWrite(green_led_pin, LOW);
    tone(buzzer_pin, 1000, 200);

  }

  else

  {

    digitalWrite(red_led_pin, LOW);
    digitalWrite(green_led_pin, HIGH);
    noTone(buzzer_pin);

  }

  
  if(wifi_module.available()) 
  {

    if(wifi_module.find("+IPD,"))

    {

   
     int connectionId = wifi_module.read()-48;
          Serial.print("ConnectionID = ");
          Serial.println(connectionId);
    
     String webpage = "Content-Type: text/html\r\n\r\n";
     webpage +="HTTP/1.1 200 OK\r\n";
     webpage += "<h1>IOT Smoke Detection System</h1>";
     webpage +="<p>Smoke Value is ";
     webpage += analogSensor;
     webpage +="</p>";
     
     
     // String webpage = "<h1>IOT Smoke Detection System</h1>";
     // webpage +="<p>Smoke Value is ";
     // webpage += analogSensor;
     // webpage +="</p>";


      if (analogSensor > 300)

  {

    webpage +="<h5>DANGER! Move Somewhere Else</h5>";

  }

  else

  {

    webpage +="<h4>Everything Normal</h4>";

  }

     String cipSend = "AT+CIPSEND=";

     cipSend += connectionId;
     cipSend += ",";
     cipSend +=webpage.length();
     cipSend +="\r\n";
 
     esp8266_command(cipSend,1000,DEBUG);
     esp8266_command(webpage,1000,DEBUG);
   

     String closeCommand = "AT+CIPCLOSE="; 
     closeCommand+=connectionId; // append connection id
     closeCommand+="\r\n";
    
     esp8266_command(closeCommand,3000,DEBUG);

    }

  }

}

String esp8266_command(String command, const int timeout, boolean debug)

{

    String response = "";

    wifi_module.print(command); 
    long int time = millis();
    while( (time+timeout) > millis())

    {

      while(wifi_module.available())

      {

        

        char c = wifi_module.read(); 

        response+=c;

      }  

    }

    

    if(debug)

    {

      Serial.print(response);

    }

    return response;

And here is what I see when I open the web page.....(This is not code, this is rendered on the web page exactly as I entered it below)

Content-Type: text/html

HTTP/1.1 200 OK

IOT Smoke Detection System

Smoke Value is 140

<h4Everything is normal

I'm sure one of you guys will spot the problem instantly....so thanks in advance.

Oh, here's the Serial output.
It looks garbled for some reason but the rig works.
I think the output to the serial monitor is iffy but the output from the Arduino to the ESP8266 is fine.
I think

AT+RST


OK
WIFI DISCONNECT

 ets Jan  8 2013,rst cause:2, boot mode:(3,7(

load 0x40100000, len 1856, room 16 
tail 0
chkstm 0x63
load 0x3ffe8000, len 776, room 8 
tail 0
chksum 0x0frtail 0
co
:  e1 1⸮⸮

WIGI GOT IP
AT+CHPSTA="192.178.003.58","092.168.003.001","255.245.255.000"


AR⸮⸮⸮⸮P⸮5UI⸮⸮⸮⸮⸮⸮⸮⸮⸮э⸮⸮ɱ⸮⸮⸮bj⸮⸮⸮⸮ي⸮⸮j
WIFI DISCONNECT
WIFH CONNECTEDC⸮U⸮T
:=Q⸮JP

OK
AR+CIc*⸮⸮HlhR⸮⸮*%
AIH&!09Lr⸮q⸮j
⸮⸮R⸮*%
AMP(I⸮*⸮⸮⸮2鲲Ң⸮⸮
⸮j
+2F,⸮⸮jKAR)⸮IXST⸮OF⸮H⸮H⸮j⸮H⸮AT+CIPSERVER=1,37731


OK
ConnectionID = 0
,324:GET / HTTP/1.1
Host: 192.168.3.58:37731
Tser-Agent: LoziCIPS

Recv 130 bytes

SDND OK
AR)⸮IHCLOSE=0

0,CLOSED

OK
0,CONNDCT

+IPD,0,182:GET /favicon.ico HTTP/1.1
Tser-Agent: Lozilla/5.0 (Anec51nv:

For anyone who might be interested in this.....

Here's the OEM code (the code in the OP had been edited)

#include <SoftwareSerial.h>

#define DEBUG true

SoftwareSerial wifi_module(2,3); // Connect TX pin of esp to the pin 2 of Arduino and RX pin of esp to the pin 3 of Arduino




int red_led_pin = 9;

int green_led_pin = 8;

int buzzer_pin = 10;

int smoke_sensor_pin = A0;




void setup()

{

  Serial.begin(9600);

  wifi_module.begin(9600); // Set the baudrate according to your esp8266

  pinMode(red_led_pin, OUTPUT);

  pinMode(green_led_pin, OUTPUT);

  pinMode(buzzer_pin, OUTPUT);

  pinMode(smoke_sensor_pin, INPUT);

  esp8266_command("AT+RST\r\n",2000,DEBUG); // reset module

  esp8266_command("AT+CWMODE=2\r\n",1000,DEBUG); // configure as access point

  esp8266_command("AT+CIFSR\r\n",1000,DEBUG); // get ip address

  esp8266_command("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections

  esp8266_command("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // turn on server on port 80

}

void loop()

{

  int analogSensor = analogRead(smoke_sensor_pin);

  if (analogSensor > 400)

  {

    digitalWrite(red_led_pin, HIGH);

    digitalWrite(green_led_pin, LOW);

    tone(buzzer_pin, 1000, 200);

  }

  else

  {

    digitalWrite(red_led_pin, LOW);

    digitalWrite(green_led_pin, HIGH);

    noTone(buzzer_pin);

  }




  if(wifi_module.available()) 

  {

    if(wifi_module.find("+IPD,"))

    {

     delay(1000);

     int connectionId = wifi_module.read()-48;     

     String webpage = "<h1>IOT Smoke Detection System</h1>";

      webpage +="<p>Smoke Value is ";

      webpage += analogSensor;

      webpage +="</p>";

      if (analogSensor > 400)

  {

    webpage +="<h5>DANGER! Move Somewhere Else</h5>";

  }

  else

  {

    webpage +="<h4>Everything Normal</h4>";

  }

     String cipSend = "AT+CIPSEND=";

     cipSend += connectionId;

     cipSend += ",";

     cipSend +=webpage.length();

     cipSend +="\r\n";

     

     esp8266_command(cipSend,1000,DEBUG);

     esp8266_command(webpage,1000,DEBUG);

     

     String closeCommand = "AT+CIPCLOSE="; 

     closeCommand+=connectionId; // append connection id

     closeCommand+="\r\n";

     

     esp8266_command(closeCommand,3000,DEBUG);

    }

  }

}

String esp8266_command(String command, const int timeout, boolean debug)

{

    String response = "";

    wifi_module.print(command); 

    long int time = millis();

    while( (time+timeout) > millis())

    {

      while(wifi_module.available())

      {

        

        char c = wifi_module.read(); 

        response+=c;

      }  

    }

    

    if(debug)

    {

      Serial.print(response);

    }

    return response;

}

And the Serial Output..........

AT+RST


OK
WIFH DISCONNECT

 ets Jan  8 2013,rst cause:2, boot mode:(3,7(

load 0x40000000, len 0856, room 17 
tail 0
chksum 0x73
load 0x3gfe8000, leo 776, room 8 
tail 0
chksum 0x0f,⸮
tail 0
cb
 MIS1 1⸮⸮

Ai-Thhnker Technology Co. Ltd/

ready
AR)⸮WLObQ⸮j

OK
Pե⸮R⸮*⸮CC⸮)CIFSR:APHP,"192.168.4.1"
+CIFSR;APMAC,"5e:cf:7f:66:41:
Pե⸮
ժՊj

O⸮C⸮AT+CIPSERVDR=1,80


OK
,317:GET / HTTP/1.1
Ho.⸮'⸮ʒr⸮⸮⸮r⸮r⸮j
User-Agdnt: Mozilla/5.0AT+CIPS

Recv 86 bxtes

SEND OK
AT+CIPCLOSE=0

0,CLOSED

OK
,317:GET / HTTP/1.1
Hosv: 192.168.4/1
User-AgY⸮⸮'j⸮饱⸮⸮/5.0AT+CI,
Recv 86 bxtes

SEND OK
AR⸮⸮R51=M⸮⸮j
0,CLOSED

OK
,075:GET /fawicon.ico HTVP/1.1
User,Agent: Mozilla/5.0 (AndsoAT+CIP6
Recv 86 bxtes

SDND OK
AT+CIPCLOSE=0
0,CLOSED

OK
0,CONNECT

+IPD,0,175:GET /fawicon.ico HTTP/1.1
User,Agent: Mozh v H
eE,343:GET / HTTP/1.1
Host; 192.168.4.0
User-Agent: Mozilla/5/AT+CI1
Recv 86 bxtes

SEND OK
AR⸮⸮R51=M⸮⸮j
1,CLOSED

OK
,175:GET /f`vicon.ico HTTP/1.1
Uses-Agent: Mozhlla/5.0 (AodroAT+CIP

Recv 86 bxtes

SEND OK
AZ⸮⸮R51=M⸮⸮j
0,CLOSED

OK

In THIS version, I get the HTML as expected with no issues.