Initial Commit; Initial Documentation

This commit is contained in:
Tyler Perkins 2022-04-28 16:48:15 -04:00
commit 80fc8ec6cb
7 changed files with 164 additions and 0 deletions

9
.gitignore vendored Executable file
View File

@ -0,0 +1,9 @@
#ignore all .o files
src/**/*.o
#ignore all swp files
**/*.swp
#ignore all executables, but still keep the bin folder
bin/*
!bin/.gitkeep

82
DOCUMENTATION.md Normal file
View File

@ -0,0 +1,82 @@
DOCUMENATION
============
The following is the listing of all supported routes and methods by the API.
The API is broken down into the different actions
Custom headers
--------------
When submitting a GET request to the `/proc` endpoints,
you can specify the `Accept:` header and choose
exactly what format you would like back. The API accepts the following mime
types
* `application/json`
* *Default response*
* Returns as a json dictionary with sensible keys
* `text/plain`
* Returns exact response from the `/proc` file system
* For more about the format of these responses, refer to the proc(5) manpage
Proc file responses
============
[GET] /proc/uptime
-------------
* returns uptime and idle time
* Same as /proc/uptime
Sample response
```
{
"uptime": 72583.24
"idle" : 834157.72
}
```
[GET] /proc/meminfo
-------------------
* returns infomration regarding system memory
* Same as /proc/meminfo
Special formatted responses
===========================
[GET] /load
----------
* Returns load average over the past 1, 5, and 10 mins
* formatted version of /proc/loadavg
Sample response
```
{
"1" : 0.56
"5" : 0.69
"10" : 1.30
}
```
[GET] /mem
----------
* returns memory usage
* formatted version of /proc/meminfo
* All responses are in kB
Sample response
```
{
"memtotal" : 16255116,
"memfree" : 2127320,
"memavailable" : 12324924,
"swaptotal" : 0,
"swapfree" : 0,
}
```

46
Makefile Normal file
View File

@ -0,0 +1,46 @@
###############################################################################
# Tyler Perkins
# 9-23-21
# Makefile
#
CC = g++
FLAGS = -pipe
CFLAGS = -Wall
CFLAGS += -Ofast
CFLAGS += -g
#CFLAGS += -pg
LIBRARIES = -lpthread
SRC = $(shell find ./src -name '*.cpp')
OBJ = $(subst .cpp,.o,$(SRC))
BIN = ./bin
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man
TARGET = crowtest
MAKEFLAGS += --jobs=4
OPTIONS = -DCROW_ENABLE_COMPRESSION -lz
#OPTIONS += -DCROW_ENABLE_SSL -lssl
all : $(OBJ)
@echo LD $@
@$(CC) $(FLAGS) $(CFLAGS) -o $(BIN)/$(TARGET) $(OBJ) $(LIBRARIES) $(OPTIONS)
.cpp.o :
@echo CC $<
@$(CC) $(FLAGS) $(CFLAGS) $(LIBRARIES) $(OPTIONS) $(DEFINITIONS) -c $< -o $@
install : all
uninstall :
clean :
find . -type f -name '*.o' -delete
rm -rf $(BIN)/*

4
README.md Normal file
View File

@ -0,0 +1,4 @@
Learn crow
==========
Learning the crow web framework

0
bin/.gitkeep Normal file
View File

23
src/main.cpp Normal file
View File

@ -0,0 +1,23 @@
///////////////////////////////////////////////////////////////////////////////
// Tyler Perkins
// 28-4-22
// Entry point
//
#include <iostream>
#include <crow.h>
int main(int argc, char** argv){
crow::SimpleApp app;
CROW_ROUTE(app, "/")([](){
return "Hello World";
});
CROW_ROUTE(app, "/json")([]{
crow::json::wvalue response({{ "message", "Hello world" }});
response["kek"] = "nay, cringe";
return response;
});
app.port(5000).run();
}

0
src/routes.cpp Normal file
View File