💾 Archived View for gemini.rmf-dev.com › repo › Vaati › UploadService › files › 13f4043f50e9c7ec3172… captured on 2023-09-08 at 16:40:53. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-04-19)
-=-=-=-=-=-=-
0 /* See LICENSE for license details. */
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <time.h>
4 #include <sys/stat.h>
5 #include "server.h"
6 #include "sandbox.h"
7
8 int main(int argc, char* argv[]) {
9 struct stat sb;
10 int ret, port = 8080;
11
12 srand(time(NULL));
13
14 ret = stat("download", &sb);
15 if ((ret && mkdir("download", 0700)) ||
16 (!ret && !S_ISDIR(sb.st_mode))) {
17 printf("Failed to create download directory\n");
18 return -1;
19 }
20
21 if (argc > 1) {
22 port = atoi(argv[1]);
23 if (!port) port = 8080;
24 }
25
26 load_file("static/index.html", "/", "text/html");
27 load_file("static/upload.html", "/upload", "text/html");
28 load_file("static/favicon.ico", "/favicon.ico", "image/x-icon");
29 sandbox_start();
30
31 if (server_init(port)) {
32 printf("Failed to initialize the server\n");
33 return -1;
34 }
35 server_thread();
36 server_stop();
37
38 return 0;
39 }
40