evil 1.0.0
dotnet add package evil --version 1.0.0
NuGet\Install-Package evil -Version 1.0.0
<PackageReference Include="evil" Version="1.0.0" />
paket add evil --version 1.0.0
#r "nuget: evil, 1.0.0"
// Install evil as a Cake Addin #addin nuget:?package=evil&version=1.0.0 // Install evil as a Cake Tool #tool nuget:?package=evil&version=1.0.0
The EVIL! Web Framework
EVIL! (or Evil, or even evil) is a C# web framework inspired by Python modules like Flask and Tornado. It aims to provide a simple way to write web applications with no external dependencies, to avoid bloating your project with code you aren't using.
Evil depends on the standard library and can be summarized as a 'wrapper'. It handles routing requests to methods, and provides a thin wrapper for HttpListener classes. It does not provide an authentication library, or templating, or anything above handling and routing requests. It is, however, trivial to implement these things yourself using the tools Evil provides.
To write an Evil application, you have to options. You can subclass Evil.WebApplication, or simply create an instance of it. You can define a function like this:
public static void HellorldRoute(string method, string[] groups, Request req, Response res) {
req.ContentType = "text/html";
req.SetBody("<h1>Hello, world!</h1>");
}
and then define the application like so:
public static async Task Main(string[] args) {
// Verbose = true enables logging for each request
WebApplication app = new WebApplication() { Verbose = true };
// The second argument is regex for matching the request path
app.RegisterRoute("get", "(.*)", HellorldRoute);
// If you subclass WebApplication, you SHOULD NOT define prefixes from your
// class's initializer!
app.Prefixes.Add("http://localhost:60080/");
await app.Run();
}
Now, if you point your browser to localhost:60080, you should see a big header that says "Hello, world!". Cool!
Bugs
If you find a bug:
Patch it!
Evil welcomes contributors at codeberg.org. However, if you aren't comfortable writing server code (understandably)...
Report it!
You can visit the issues tab to report any issues you're not aware of the solution for. If you don't have an account on Codeberg and don't feel like creating one, you can email me at tobskep@aol.com.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 71 | 8 months ago |