Guest User

Untitled

a guest
Jul 19th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. void data()
  2. {
  3. if(SPIFFS.exists("/login.html"))
  4. {
  5. Serial.println();
  6. }
  7. else{
  8. SPIFFS.begin();
  9. File f=SPIFFS.open("/login.html","w");
  10. String s="<html><head><title>AP</title><h1>Welcome to AP page</h1>n";
  11. s+="</head><body><form name="/myform" action="/login" method="POST">n";
  12. s+="<input type="text" name="username" placeholder="username"><br/>n";
  13. s+="<input type="password" name="password" placeholder="password"><br/>n";
  14. s+="<input type="submit" value="login"></form></body></html>";
  15. f.println(s);
  16. f.close();
  17. }
  18.  
  19. }
  20.  
  21. WiFi.mode(WIFI_AP_STA);//Only Access point
  22. WiFi.softAP(ssid, password); //Start HOTspot removing password will disable security
  23.  
  24. IPAddress myIP = WiFi.softAPIP(); //Get IP address
  25. Serial.print("HotSpt IP:");
  26. Serial.println(myIP);
  27.  
  28. server.on("/", HTTP_GET, handleRoot); //Which routine to handle at root location
  29. server.on("/",HTTP_POST,handlelogin);
  30. server.onNotFound(handleerror);
  31.  
  32. server.begin();
  33.  
  34. void handleRoot()
  35. {
  36. SPIFFS.begin();
  37. File f=SPIFFS.open("/login.html","r");
  38. server.send(200, "text/html",f.readStringUntil('EOF'));
  39. }
Add Comment
Please, Sign In to add comment