Add hello world example

This commit is contained in:
Alex Hultman
2018-10-28 02:28:02 +01:00
parent 4059dd644c
commit ba83c9156a
2 changed files with 26 additions and 1 deletions
+12 -1
View File
@@ -1,14 +1,25 @@
default:
.PHONY: examples
examples:
# HelloWorld
rm *.o
clang -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c
clang++ -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/HelloWorld.cpp
clang++ -flto -O3 -s *.o -o HelloWorld
# HttpServer (currently quire broken, mind you)
rm *.o
clang -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c
clang++ -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/HttpServer.cpp
clang++ -flto -O3 -s *.o -o HttpServer -lssl -lcrypto -lpthread -lstdc++fs
# I don't know what this is supposed to do
main:
rm *.o
clang -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c
clang++ -flto -O3 -c -std=c++17 -Isrc -IuSockets/src main.cpp
clang++ -flto -O3 -s *.o -o uWS_main -lssl -lcrypto -lpthread
# I don't have any tests yet
tests:
rm *.o
clang -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c
+14
View File
@@ -0,0 +1,14 @@
#include "App.h"
int main() {
/* Overly simple hello world app */
uWS::App().get("/*", [](auto *res, auto *req) {
res->end("Hello world!");
}).listen(3000, [](auto *token) {
if (token) {
std::cout << "Listening on port " << 3000 << std::endl;
}
}).run();
std::cout << "Failed to listen on port 3000" << std::endl;
}