Error in my code - please, help me

My code presents this problem bellow. Someone help me?

TESTE:59:1: error: 'server' does not name a type

server.on("/temperature", HTTP_GET, getTemperature);

^

TESTE:63:1: error: 'server' does not name a type

server.on("/humidity", HTTP_GET, getHumidity);

^

TESTE:69:1: error: 'server' does not name a type

server.on("/monitor", HTTP_GET, showMonitor);

^

TESTE:72:1: error: 'server' does not name a type

server.onNotFound(onNotFound);

^

TESTE:75:1: error: 'server' does not name a type

server.begin();

^

TESTE:76:1: error: 'Serial' does not name a type

Serial.println("Servidor HTTP iniciado");

^

TESTE:77:1: error: expected declaration before '}' token

}

^

exit status 1
'server' does not name a type

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <DHT.h>



ESP8266WebServer server(80);

DHT dht (2, DHT22);

void setup()
{
 
 Serial.begin(115200);
 
 
 WiFi.begin("Maxprint-150", "192468");

 Serial.print("");
 Serial.print("Conectando");


 
 while (WiFi.status() != WL_CONNECTED)
 {
   //Esperamos 100 milisegundos
   delay(500);
   Serial.print(".");
 }
 

 pinMode(0, OUTPUT);

 digitalWrite(0, LOW);


 Serial.println("");
 Serial.println("Conectou");

 //Configurações do IP fixo. Você pode alterar conforme a sua rede
 IPAddress ip(192, 168, _, _);
 IPAddress gateway(192, 168, _, _);
 IPAddress subnet(255, 255, 255, 0);
 Serial.print("Configurando IP fixo para : ");
 Serial.println(ip);

 
 WiFi.config(ip, gateway, subnet);

 
 Serial.print("Server em: ");
 Serial.println(WiFi.localIP());
}

server.on("/temperature", HTTP_GET, getTemperature);


server.on("/humidity", HTTP_GET, getHumidity);


server.on("/monitor", HTTP_GET, showMonitor);


server.onNotFound(onNotFound);


server.begin();
Serial.println("Servidor HTTP iniciado");
}

void loop()

server.handleClient();
}


void onNotFound()
{
 server.send(404, "text/plain", "Not Found" );
}


void getTemperature()
{
 

 float t = dht.readTemperature();


 String json = "{\"temperature\":" + String(t) + "}";


 server.send (200, "application/json", json);
}


void getHumidity()
{


 float h = dht.readHumidity();

 String json = "{\"humidity\":" + String(h) + "}";


 server.send(200, "application/json", json);
}

void showMonitor()


String html =
 "<html>"
 "<head>"
 "<meta name='viewport' content='width=device-width, initial-scale=1, user-scalable=no'/>"
 "<title>SiloAgri</title>"
 "<style type='text/css'>"
 "body{"
 "padding: 35px;"
 "background-color: #222222;"
 "}"
 "h1{"
 "color: #FFFFFF;"
 "font-family: sans-serif;"
 "}"
 "p{"
 "color: #EEEEEE;"
 "font-family: sans-serif;"
 "font-size:18px;"
 "}"
 "</style>"
 "</head>"
 "<body>"
 "<h1>DHT Monitor</h1>"
 "<p id='temperature'>Temperature: </p>"
 "<p id='humidity'>Humidity: </p>"
 "</body>"
 "<script type='text/javascript'>"
 "refresh();"
 "setInterval(refresh, 5000);"
 "function refresh()"
 "{"
 "refreshTemperature();"
 "refreshHumidity();"
 "}"
 "function refreshTemperature()"
 "{"
 "var xmlhttp = new XMLHttpRequest();"
 "xmlhttp.onreadystatechange = function() {"
 "if (xmlhttp.readyState == XMLHttpRequest.DONE && xmlhttp.status == 200){"
 "document.getElementById('temperature').innerHTML = 'Temperature: ' + JSON.parse(xmlhttp.responseText).temperature + 'C';"
 "}"
 "};"
 "xmlhttp.open('GET', 'http://192.168.10.1/temperature', true);"
 "xmlhttp.send();"
 "}"
 "function refreshHumidity()"
 "{"
 "var xmlhttp = new XMLHttpRequest();"
 "xmlhttp.onreadystatechange = function() {"
 "if (xmlhttp.readyState == XMLHttpRequest.DONE && xmlhttp.status == 200){"
 "document.getElementById('humidity').innerHTML = 'Humidity: ' + JSON.parse(xmlhttp.responseText).humidity + '%';"
 "}"
 "};"
 "xmlhttp.open('GET', 'http://192.168.10.1/humidity', true);"
 "xmlhttp.send();"
 "}"
 "</script>"
 "button{"
 "outline: none;"
 "border: 2px solid #1fa3ec;"
 "border-radius:18px;"
 "background-color:#FFF;"
 "color: #1fa3ec;"
 "padding: 10px 50px;"
 "}"

 "button:active{"
 "color: #fff;"
 "background-color:#1fa3ec;"
 "}"
 "</style>"
 "</head>"
 "<body>"
 "<p>GPIO0</p>"
 "<p><a href='?acao=gpio0On'><button>ON</button></a></p>"
 "<p><a href='?acao=gpio0Off'><button>OFF</button></a></p>"
 "<p>GPIO2</p>"
 "<p><a href='?acao=gpio2On'><button>ON</button></a></p>"
 "<p><a href='?acao=gpio2Off'><button>OFF</button></a></p>"
 "</body>"
 "</html>";
server.send(200, "text/html", html);


client.print(html);


client.flush();


if (req.indexOf("acao=gpio0On") != -1)
{

 digitalWrite(0, HIGH);
}


else if (req.indexOf("acao=gpio0Off") != -1)

{

 digitalWrite(0, LOW);
}


client.stop();
Serial.println("Cliente desconectado");
}

So we have to dig through your poorly formatted and improperly posted code to try to find your problems? Would it not be easier for us if you told us what the code actually does and how that differs from what you want the code to do? Are there compile errors? Post the entire text of the error messages.

Read the How to use this forum stickies (at the top of every topic in bold) to see how to post code and error messages.

Use auto format to format your code to make it easier to read. Use ctrl-t or in the IDE menus, Tools, Auto Format.

groundFungus:
So we have to dig through your poorly formatted and improperly posted code to try to find your problems? Would it not be easier for us if you told us what the code actually does and how that differs from what you want the code to do? Are there compile errors? Post the entire text of the error messages.

Read the How to use this forum stickies (at the top of every topic in bold) to see how to post code and error messages.

Use auto format to format your code to make it easier to read. Use ctrl-t or in the IDE menus, Tools, Auto Format.

Thank you. Now could you help me, please?

Serial.print("Server em: ");
 Serial.println(WiFi.localIP());
}  //  this bracket ends the setup() function. The code after is outside a function caustng an error.

server.on("/temperature", HTTP_GET, getTemperature);
void loop()

server.handleClient();
}

Missing something here.

void showMonitor()


String html =
 "<html>"
 "<head>"

Missing an opening curly bracket at least.

@WagnerVitor, do not cross-post. Other threads removed.

As I said in a similar thread, possibly one of your other on the same subject, where is the object named server declared in the code ?

If you don't understand the question then look at how the dht object is declared so that it can be used in the program

#include <DHT.h>

DHT dht (2, DHT22);