user27363: In the past I uploaded the code below:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <DHT.h>

#define DHTTYPE DHT22     // DHT 11
#define DHTPIN D5
DHT dht(DHTPIN, DHTTYPE);

const char *ssid = " Hello_IOT";
const char *pass = "12345678";
String command;
ESP8266WebServer server(8080);

void respond(){
  int h = dht.readHumidity();
  int t = dht.readTemperature();
  server.send(200, "text/html", "<h1>Hello from Wemos R1 Mini</h1>");
}

void outputJson(){
  char temp[400];
  int h = dht.readHumidity();
  int t = dht.readTemperature();
  int tf = dht.readTemperature(true);
  snprintf(temp, 400, "{\"wittyCloud\" : [{\"location\" : \"any\" ,\
    \"temperatureInC\" :%d ,\
    \"temperatureInF\" :%d ,\
    \"humidity\":%d,\
    \"ldr\":%d\
    }]}",
  t, tf, h, analogRead(A0));
  server.send(200, "text/json", temp);
}

void setup(){
  Serial.begin(115200);
  pinMode(BUILTIN_LED, OUTPUT);
  Serial.println("Connect to access Point");
  WiFi.softAP(ssid, pass);
  IPAddress IPserver = WiFi.softAPIP();
  Serial.println(" IP address server : ");
  Serial.println(IPserver);
  server.on("/", respond);
  server.on("/json", outputJson);
  server.begin();
  server.onNotFound([](){
    command = server.uri();
    server.send(200, "text/plain", command);
  });
}

void loop(){
  server.handleClient();
  if(command.equals("/mati")){
    digitalWrite(BUILTIN_LED, HIGH); //turn off BUILTIN LED
  }
  if(command.equals("/hidup")){
    digitalWrite(BUILTIN_LED, LOW); //turn on BUILTIN LED
  }
}

For learning purpose it worked, however when I modified it to the code below for WeMOS, to connect to my home wifi router, it creates instead an access point, and on opening the URL after connecting to the WeMOS access point it displays the web page of the updated code.
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266mDNS.h>
#include <ESP8266WebServer.h>
#include "control.h"
#include "webpage.h"
#include <DHT.h>

ESP8266WebServer server(80);
const char* sid = "router+ssid";
const char* passwd = "ssid_password";

#define DHTTYPE DHT22     // DHT 22
#define DHTPIN D5
DHT dht(DHTPIN, DHTTYPE);
const char* host = "nodemcu";

void outputJson(){
  char temp[400];
  int h = dht.readHumidity();
  int t = dht.readTemperature();
  int tf = dht.readTemperature(true);
  snprintf(temp, 400, "{\"wemos\" : [{\"location\" : \"bangalore\" ,\
    \"temperatureInC\" :%2d ,\
    \"temperatureInF\" :%2d ,\
    \"humidity\":%2d\
    }]}",
  t, tf, h);
  server.send(200, "text/json", temp);
}

void handleRoot(){
  const int nsize = 2300;
  char temp[nsize];
  delay(200);
  int h = dht.readHumidity();
  int t = dht.readTemperature();
  snprintf(temp, nsize,
    "%s\n<!-- add btns here --></\div></body>\n\
    </html>",webpage::html);
  server.send(200, "text/html", temp);
}

void handleNotFound(){
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message +=(server.method()== HTTP_GET)? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for(uint8_t i = 0; i < server.args(); i++){
    message += " " + server.argName(i)+ ": " + server.arg(i)+ "\n";
  }
  server.send(404, "text/plain", message);
}

void setup(void) {
  Serial.begin(9600);
  // config static IP
  IPAddress ip(192, 168, 1, 88);
  IPAddress gateway(192, 168, 1, 1);
  IPAddress subnet(255, 255, 255, 0);
  IPAddress dns(192, 168, 1, 1);
  WiFi.config(ip, dns, gateway, subnet);
  WiFi.begin(sid, passwd);
  Serial.println("");
  EEPROM.begin(512);

  // Wait for connection
  while(WiFi.status()!= WL_CONNECTED){
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(sid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  if(MDNS.begin(host)){
    Serial.println("MDNS responder started");
  }
  MDNS.addService("http", "tcp", 80);
  server.on("/", handleRoot);
  server.on("/json", outputJson);
  server.on("/control", control::toggleRelay);
  server.onNotFound(handleNotFound);
  server.begin();
  Serial.println(F("HTTP server started"));
}

void loop(void){
  server.handleClient();
}


user-1: 
it creates instead an access point

Did you use setmode() to put it in station mode?
wifi.setmode()
Configures the WiFi mode to use. NodeMCU can run in one of four WiFi modes:

Station mode, where the NodeMCU device joins an existing network.
Access point (AP) mode, where it creates its own network that others can join.
Station + AP mode, where it both creates its own network while at the same time being joined to another existing network.
WiFi off.

When using the combined Station + AP mode, the same channel will be used for both networks as the radio can only listen on a single channel.
NOTE: WiFi Mode configuration will be retained until changed even if device is turned off.
Syntax
wifi.setmode(mode)

Parameters
mode value should be one of

wifi.STATION for when the device is connected to a WiFi router. This is often done to give the device access to the Internet.
wifi.SOFTAP for when the device is acting only as an access point. This will allow you to see the device in the list of WiFi networks (unless you hide the SSID, of course). In this mode your computer can connect to the device, creating a local area network. Unless you change the value, the NodeMCU device will be given a local IP address of 192.168.4.1 and assign your computer the next available IP address, such as 192.168.4.2.
wifi.STATIONAP is the combination of wifi.STATION and wifi.SOFTAP. It allows you to create a local WiFi connection and connect to another WiFi router.   
wifi.NULLMODE to switch off WiFi

Returns
current mode after setup

WeMOS access point it displays the web page of the updated code

I think @Ciasto answered that part.

27363: <p>In the past I uploaded the code below:</p>

<pre><code>#include &lt;ESP8266WiFi.h&gt;
#include &lt;WiFiClient.h&gt;
#include &lt;ESP8266WebServer.h&gt;
#include &lt;DHT.h&gt;

#define DHTTYPE DHT22     // DHT 11
#define DHTPIN D5
DHT dht(DHTPIN, DHTTYPE);

const char *ssid = " Hello_IOT";
const char *pass = "12345678";
String command;
ESP8266WebServer server(8080);

void respond(){
  int h = dht.readHumidity();
  int t = dht.readTemperature();
  server.send(200, "text/html", "&lt;h1&gt;Hello from Wemos R1 Mini&lt;/h1&gt;");
}

void outputJson(){
  char temp[400];
  int h = dht.readHumidity();
  int t = dht.readTemperature();
  int tf = dht.readTemperature(true);
  snprintf(temp, 400, "{\"wittyCloud\" : [{\"location\" : \"any\" ,\
    \"temperatureInC\" :%d ,\
    \"temperatureInF\" :%d ,\
    \"humidity\":%d,\
    \"ldr\":%d\
    }]}",
  t, tf, h, analogRead(A0));
  server.send(200, "text/json", temp);
}

void setup(){
  Serial.begin(115200);
  pinMode(BUILTIN_LED, OUTPUT);
  Serial.println("Connect to access Point");
  WiFi.softAP(ssid, pass);
  IPAddress IPserver = WiFi.softAPIP();
  Serial.println(" IP address server : ");
  Serial.println(IPserver);
  server.on("/", respond);
  server.on("/json", outputJson);
  server.begin();
  server.onNotFound([](){
    command = server.uri();
    server.send(200, "text/plain", command);
  });
}

void loop(){
  server.handleClient();
  if(command.equals("/mati")){
    digitalWrite(BUILTIN_LED, HIGH); //turn off BUILTIN LED
  }
  if(command.equals("/hidup")){
    digitalWrite(BUILTIN_LED, LOW); //turn on BUILTIN LED
  }
}
</code></pre>

<p>For learning purpose it worked, however when I modified it to the code below for WeMOS, to connect to my home wifi router, it creates instead an access point, and on opening the URL after connecting to the WeMOS access point it displays the web page of the updated code.</p>

<pre><code>#include &lt;ESP8266WiFi.h&gt;
#include &lt;WiFiClient.h&gt;
#include &lt;ESP8266mDNS.h&gt;
#include &lt;ESP8266WebServer.h&gt;
#include "control.h"
#include "webpage.h"
#include &lt;DHT.h&gt;

ESP8266WebServer server(80);
const char* sid = "router+ssid";
const char* passwd = "ssid_password";

#define DHTTYPE DHT22     // DHT 22
#define DHTPIN D5
DHT dht(DHTPIN, DHTTYPE);
const char* host = "nodemcu";

void outputJson(){
  char temp[400];
  int h = dht.readHumidity();
  int t = dht.readTemperature();
  int tf = dht.readTemperature(true);
  snprintf(temp, 400, "{\"wemos\" : [{\"location\" : \"bangalore\" ,\
    \"temperatureInC\" :%2d ,\
    \"temperatureInF\" :%2d ,\
    \"humidity\":%2d\
    }]}",
  t, tf, h);
  server.send(200, "text/json", temp);
}

void handleRoot(){
  const int nsize = 2300;
  char temp[nsize];
  delay(200);
  int h = dht.readHumidity();
  int t = dht.readTemperature();
  snprintf(temp, nsize,
    "%s\n&lt;!-- add btns here --&gt;&lt;/\div&gt;&lt;/body&gt;\n\
    &lt;/html&gt;",webpage::html);
  server.send(200, "text/html", temp);
}

void handleNotFound(){
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message +=(server.method()== HTTP_GET)? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for(uint8_t i = 0; i &lt; server.args(); i++){
    message += " " + server.argName(i)+ ": " + server.arg(i)+ "\n";
  }
  server.send(404, "text/plain", message);
}

void setup(void) {
  Serial.begin(9600);
  // config static IP
  IPAddress ip(192, 168, 1, 88);
  IPAddress gateway(192, 168, 1, 1);
  IPAddress subnet(255, 255, 255, 0);
  IPAddress dns(192, 168, 1, 1);
  WiFi.config(ip, dns, gateway, subnet);
  WiFi.begin(sid, passwd);
  Serial.println("");
  EEPROM.begin(512);

  // Wait for connection
  while(WiFi.status()!= WL_CONNECTED){
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(sid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  if(MDNS.begin(host)){
    Serial.println("MDNS responder started");
  }
  MDNS.addService("http", "tcp", 80);
  server.on("/", handleRoot);
  server.on("/json", outputJson);
  server.on("/control", control::toggleRelay);
  server.onNotFound(handleNotFound);
  server.begin();
  Serial.println(F("HTTP server started"));
}

void loop(void){
  server.handleClient();
}
</code></pre>
 -1: <blockquote>
  <p>it creates instead an access point</p>
</blockquote>

<p>Did you use setmode() to put it in station mode?</p>

<p><strong>wifi.setmode()</strong></p>

<p>Configures the WiFi mode to use. NodeMCU can run in one of four WiFi modes:</p>

<ul>
<li>Station mode, where the NodeMCU device joins an existing network.</li>
<li>Access point (AP) mode, where it creates its own network that others can join.</li>
<li>Station + AP mode, where it both creates its own network while at the same time being joined to another existing network.</li>
<li>WiFi off.</li>
</ul>

<p>When using the combined Station + AP mode, the same channel will be used for both networks as the radio can only listen on a single channel.</p>

<p>NOTE: WiFi Mode configuration will be retained until changed even if device is turned off.</p>

<p><strong>Syntax</strong></p>

<pre><code>wifi.setmode(mode)
</code></pre>

<p><strong>Parameters</strong></p>

<p>mode value should be one of</p>

<ul>
<li>wifi.STATION for when the device is connected to a WiFi router. This is often done to give the device access to the Internet.</li>
<li>wifi.SOFTAP for when the device is acting only as an access point. This will allow you to see the device in the list of WiFi networks (unless you hide the SSID, of course). In this mode your computer can connect to the device, creating a local area network. Unless you change the value, the NodeMCU device will be given a local IP address of 192.168.4.1 and assign your computer the next available IP address, such as 192.168.4.2.</li>
<li>wifi.STATIONAP is the combination of wifi.STATION and wifi.SOFTAP. It allows you to create a local WiFi connection and connect to another WiFi router.   </li>
<li>wifi.NULLMODE to switch off WiFi</li>
</ul>

<p><strong>Returns</strong></p>

<p>current mode after setup</p>

<blockquote>
  <p>WeMOS access point it displays the web page of the updated code</p>
</blockquote>

<p>I think @Ciasto answered that part.</p>
