mimetype check beta

This commit is contained in:
Win 2024-05-24 20:03:15 +07:00
parent 218e41082c
commit c944c6ed63
2 changed files with 25 additions and 0 deletions

View File

@ -24,5 +24,29 @@ void get_file_path(char *uri, char *file_path) {
}
void get_mime_type(char *file, char *mime) {
const char *dot = strrchr(file, '.');
if (dot == NULL)
strcpy(mime, "text/html");
else if (strcmp(dot, ".html") == 0)
strcpy(mime, "text/html");
else if (strcmp(dot, ".css") == 0)
strcpy(mime, "text/css");
else if (strcmp(dot, ".js") == 0)
strcpy(mime, "application/js");
else if (strcmp(dot, ".jpg") == 0)
strcpy(mime, "image/jpeg");
else if (strcmp(dot, ".png") == 0)
strcpy(mime, "image/png");
else if (strcmp(dot, ".gif") == 0)
strcpy(mime, "image/gif");
else
strcpy(mime, "text/html");
}

View File

@ -1,3 +1,4 @@
#define MAX_PATH_SIZE 4096
void get_file_path(char *uri, char *file_path);
void get_mime_type(char *file, char *mime);