41 lines
1.0 KiB
C#
41 lines
1.0 KiB
C#
using System.Diagnostics;
|
|
using System.Net;
|
|
using Tarpit;
|
|
/*
|
|
const string filePath = "/home/skingging/Documents/Projects/CSharp/AI-Tarpit/Tarpit/words/wordlist.txt";
|
|
WordPredictor predictor = new(filePath);
|
|
string inputWord = Console.ReadLine() ?? string.Empty;
|
|
List<string?> predictedWord = predictor.PredictNextWord(inputWord.ToLower());
|
|
*/
|
|
|
|
|
|
const string baseAddress = "http://localhost:10000/";
|
|
|
|
|
|
HttpListener listener = new();
|
|
listener.Prefixes.Add(baseAddress);
|
|
|
|
ServerUtils serverUtils = new();
|
|
|
|
try
|
|
{
|
|
listener.Start();
|
|
Console.WriteLine("Listening on " + baseAddress);
|
|
|
|
while (true)
|
|
{
|
|
HttpListenerContext context = await listener.GetContextAsync();
|
|
await serverUtils.ProcessRequestAsync(context);
|
|
}
|
|
}
|
|
catch (HttpListenerException ex)
|
|
{
|
|
Console.WriteLine("Error starting or running the listener: " + ex.Message);
|
|
Console.WriteLine("Make sure you have the necessary permissions (requires running as administrator sometimes)");
|
|
}
|
|
finally
|
|
{
|
|
listener.Stop();
|
|
listener.Close();
|
|
}
|