diff --git a/public/image.jpg b/public/image.jpg new file mode 100644 index 0000000..af71d38 Binary files /dev/null and b/public/image.jpg differ diff --git a/public/includetest.html b/public/includetest.html new file mode 100644 index 0000000..fcecc5a --- /dev/null +++ b/public/includetest.html @@ -0,0 +1,14 @@ + + + + Document + + + +
+

Demo page

+

If you are seeing this then the server is working :)

+ +
+ + \ No newline at end of file diff --git a/public/index.css b/public/index.css new file mode 100644 index 0000000..ae415ca --- /dev/null +++ b/public/index.css @@ -0,0 +1,27 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +#root { + width: 100vw; + height: 100vh; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + background-color: aqua; +} + +h1 { + font-size: 3rem; +} + +p { + font-size: 1.5rem; +} + +a { + font-size: 1.5rem; +} \ No newline at end of file diff --git a/public/index.html b/public/index.html index b932471..dcd081d 100644 --- a/public/index.html +++ b/public/index.html @@ -31,6 +31,7 @@

Demo page

If you are seeing this then the server is working :)

+

Click here to see an example of including css and js as separate files

\ No newline at end of file diff --git a/public/script.js b/public/script.js new file mode 100644 index 0000000..60e8c6e --- /dev/null +++ b/public/script.js @@ -0,0 +1,4 @@ +const button = document.createElement('button'); +button.textContent = 'Click me!'; +button.onclick = () => alert('You clicked the button!'); +document.body.appendChild(button); diff --git a/response_builder.c b/response_builder.c index 5b7ae30..c20dee4 100644 --- a/response_builder.c +++ b/response_builder.c @@ -16,16 +16,13 @@ void response_handle_get(http_request* req, http_response* res) { if (strcmp(ptr, ".html") == 0) { response_build_static_file(file_path, HTML, OK, res); } else if (strcmp(ptr, ".jpg") == 0) { - serve_404(res); - return; + response_build_static_file(file_path, JPG, OK, res); } else if (strcmp(ptr, ".png") == 0) { response_build_static_file(file_path, PNG, OK, res); } else if (strcmp(ptr, ".css") == 0) { - serve_404(res); - return; + response_build_static_file(file_path, CSS, OK, res); } else if (strcmp(ptr, ".js") == 0) { - serve_404(res); - return; + response_build_static_file(file_path, JS, OK, res); } else { serve_404(res); return;