Skip to content

Commit

Permalink
Generate Arduino web project
Browse files Browse the repository at this point in the history
  • Loading branch information
lasselukkari committed Mar 19, 2019
1 parent 68190bf commit 1091a2e
Show file tree
Hide file tree
Showing 4 changed files with 1,782 additions and 0 deletions.
31 changes: 31 additions & 0 deletions BlinkServer/BlinkServer.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <WiFi.h>
#include "aWOT.h"

#define WIFI_SSID "network"
#define WIFI_PASSWORD "password"

WiFiServer server(80);
Application app;

void setup() {
Serial.begin(115200);

WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(WiFi.localIP());

app.route(staticFiles());

server.begin();
}

void loop() {
WiFiClient client = server.available();

if (client.connected()) {
app.process(&client);
}
}
21 changes: 21 additions & 0 deletions BlinkServer/StaticFiles.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
void static_index(Request &req, Response &res) {
P(index) =
"<html>\n"
"<head>\n"
"<title>Hello World!</title>\n"
"</head>\n"
"<body>\n"
"<h1>Greetings middle earth!</h1>\n"
"</body>\n"
"</html>";

res.set("Content-Type", "text/html");
res.printP(index);
}

Router staticFileRouter("/");

Router * staticFiles() {
staticFileRouter.get("", &static_index);
return &staticFileRouter;
}
Loading

0 comments on commit 1091a2e

Please sign in to comment.