Esp8266 cant upload to webserver from it's serial monitor..Help

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <NTPClient.h>
#include <WiFiUdp.h>

const long utcOffsetInSeconds = 10800;
NTPClient timeClient(ntpUDP, "", utcOffsetInSeconds);
unsigned long epochTime = timeClient.getEpochTime();
struct tm *ptm = gmtime ((time_t *)&epochTime);

const char* ssid = "";
const char* password = "

ESP8266WebServer server(80);

String SendHTML(String ID , String TimeWeb, String DateWeb);
void handle_OnConnect();
void handle_NotFound();

String ID;
String formattedTime;
String Date;
int Day;
int Month;
int Year;

void setup() {

Serial.println("Connecting to ");

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
Serial.println("Connected to WiFi");
Serial.print("IP: "); Serial.println(WiFi.localIP());

server.on("/", handle_OnConnect);
server.begin(); //Start the server
Serial.println("Server listening");
void loop() {
if (Serial.available()) {


void handle_OnConnect() {


unsigned long epochTime = timeClient.getEpochTime();
String formattedTime = timeClient.getFormattedTime();

struct tm *ptm = gmtime ((time_t *)&epochTime);

int monthDay = ptm->tm_mday;
int currentMonth = ptm->tm_mon+1;
int currentYear = ptm->tm_year+1900;

formattedTime = timeClient.getFormattedTime();
Date = String(currentYear) + "-" + String(currentMonth) + "-" + String(monthDay);
ID = Serial.write(;
server.send(200, "text/html", SendHTML(ID,formattedTime,Date));

void handle_NotFound(){
server.send(404, "text/plain", "Not found");

String SendHTML(String ID, String TimeWeb,String DateWeb){
String ptr = " \n";
ptr +="<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">\n";
ptr +="ESP8266 Hosp Server\n";

ptr +="\n";
ptr +="\n";
ptr +="<div id="webpage">\n";
ptr +="

ESP8266 Hosp Server


ptr +="

Date: ";
ptr +=(String)DateWeb;
ptr +="

ptr +="

Time: ";
ptr +=(String)TimeWeb;
ptr +="

ptr +="

ID: ";
ptr +=(String) ID;
ptr +="


ptr +="\n";
ptr +="\n";
ptr +="\n";
return ptr;

You should post code by using code-tags
Hi Ikaterot,

welcome to the forum.
To get the best out of this forum you should take time to read this

You should post code as a code-section:

There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

For doing this you should edit your first post through using the pencil-icon below your posting.

best regards Stefan