Skip to content

Kaliumhexacyanoferrat/GenHTTP

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
December 15, 2022 17:07
December 6, 2022 14:42
API
January 6, 2023 11:54
October 20, 2022 15:28
December 6, 2022 15:09
January 6, 2023 11:54
November 12, 2020 14:58
September 17, 2020 09:10

GenHTTP Webserver

GenHTTP is a lightweight web server written in pure C# with only a few dependencies to 3rd-party libraries. The main purpose of this project is to quickly create feature rich web applications and web services written in .NET 6/7, allowing developers to concentrate on the functionality rather than on messing around with configuration files, CSS or bundling JS files. Projects are mainly written in .NET, which allows C# developers to use their familiar toolset in web application development as well.

As an example, the website of this project is hosted on a Raspberry Pi: genhttp.org

CI Coverage nuget Package

Features

  • Setup new webservices or websites in a couple of minutes using project templates
  • Embed web services and applications into your existing console, service, WPF or WinForms application
  • Projects are fully described in code - no configuration files needed
  • Optimized out of the box (e.g. by bundling resources or compressing results)
  • Small memory and storage footprint
  • Several themes available to be chosen from
  • Grade A+ security level according to SSL Labs
  • Can be used to mock HTTP responses in component testing (see MockH)

Getting Started

Project templates can be used to create apps for typical use cases with little effort. After installing the templates via dotnet new -i GenHTTP.Templates in the terminal, the templates are available via the console or directly in Visual Studio:

If you would like to extend an existing .NET application, just add a nuget reference to the GenHTTP.Core nuget package. You can then spawn a new server instance with just a few lines of code:

var content = Content.From(Resource.FromString("Hello World!"));

using var server = Host.Create()
                       .Handler(content)
                       .Defaults()
                       .Start(); // or .Run() to block until the application is shut down

When you run this sample it can be accessed in the browser via http://localhost:8080.

The documentation provides a step-by-step starting guide as well as additional information on how to implement webservices, websites, MVC style projects, or single page applications and how to host your application via Docker.

Building the Server

To build the server from source, clone this repository and run the playground project launcher for .NET 7:

git clone https://github.com/Kaliumhexacyanoferrat/GenHTTP.git
cd ./GenHTTP/Playground
dotnet run

This will build the playground project launcher with all the server dependencies and launch the server process on port 8080. You can access the playground in the browser via http://localhost:8080.

Contributing

Writing a general purpose web application server is a tremendous task, so any contribution is very welcome. Besides extending the server core, you might want to

  • Extend the content capabilities of the server (e.g. by adding a new serialization format or rendering engine)
  • Add a new theme
  • Refine our project templates
  • Perform code reviews
  • Analyze the performance or security of the server
  • Clarfify and extend our tests
  • Improve the documentation on the website or in code

If you would like to contribute, please also have a look at the contribution guidelines and the good first issues.

History

The web server was originally developed in 2008 to run on a netbook with an Intel Atom processor. Both IIS and Apache failed to render dynamic pages on such a slow CPU back then. The original project description can still be found on archive.org. In 2019, the source code has been moved to GitHub with the goal to rework the project to be able to run dockerized web applications written in C#.

Links

Thanks