Everything has basically been implemented.

This commit is contained in:
2025-05-19 21:16:38 +02:00
parent 4cec4644fa
commit 5ca72cad99
10 changed files with 108 additions and 125 deletions
-14
View File
@@ -17,18 +17,4 @@ struct MetricsExporter {
static void send_data(int client_fd, const string& data);
};
const string HTML_RESPONSE_HEADER_lol =
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html; charset=utf-8\r\n"
"Transfer-Encoding: chunked\r\n"
//"Cache-control: max-age=12000\r\n"
"Connection: close\r\n\r\n";
const string BEGINNING =
"<!DOCTYPE html>\n<html><head>\r\n"
"<title>Drip</title>\r\n"
"</head><body>\r\n";
const string END = "</body></html>\r\n";
#endif
+14
View File
@@ -0,0 +1,14 @@
#ifndef OPTIONS_H
#define OPTIONS_H
#include <string>
using namespace std;
class Options {
public:
string word_lists;
string images;
string css;
};
#endif
+4 -6
View File
@@ -6,17 +6,17 @@
#include "../include/DataType.h"
#include "../include/Track.h"
#include "../include/ConcurrentQueue.h"
#include "../include/Options.h"
using namespace std;
class ServerUtils {
public:
static void serve(shared_ptr<ConcurrentQueue<Track>> cq_track);
static void serve(shared_ptr<ConcurrentQueue<Track>> cq_track, const Options& options);
private:
static void process_request(int client_fd);
static void send_header(int client_fd, data_type type);
static void send_chunked_html(int client_fd, size_t hash);
static void send_chunked_css(int client_fd);
static void send_html(int client_fd, size_t hash);
static void send_css(int client_fd);
static void send_data(int client_fd, const string& data);
static void send_image(int client_fd, const string& path, image_type type);
static size_t send_all(int client_fd, const char* data, size_t length);
@@ -26,14 +26,12 @@ class ServerUtils {
const string HTML_RESPONSE_HEADER =
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html; charset=utf-8\r\n"
"Transfer-Encoding: chunked\r\n"
"Cache-control: max-age=12000\r\n"
"Connection: close\r\n\r\n";
const string CSS_RESPONSE_HEADER =
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/css; charset=utf-8\r\n"
"Transfer-Encoding: chunked\r\n"
"Cache-control: max-age=12000\r\n"
"Connection: close\r\n\r\n";
+1 -1
View File
@@ -10,7 +10,7 @@ using namespace std;
struct WordUtils {
static unordered_map<string, unordered_map<string, int>> load_data(const string& path);
static vector<string> load_css(const string& path);
static string load_css(const string& path);
static vector<string> predict_next_word(const string& input, const unordered_map<string, unordered_map<string, int>>& word_frequencies, size_t count);
static vector<string> predict_next_word_2(const string& input, const unordered_map<string, unordered_map<string, int>>& word_frequencies, size_t count);
static string load_file(const string& path);