Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/ DevServer Public

Development server suitable for embedding in dotnet / corert applications.

Notifications You must be signed in to change notification settings

waf/DevServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3 Commits

Repository files navigation

Dev Server

A very simple development server built on top of HttpListener. Intended to be embedded in command line applications.

  • Works in CoreRT with AOT compilation (no reflection). This is the main benefit over embedding Kestrel.
  • Supports serving local files, default index.html, and directory listings
  • Supports a simple, optional "live-reload" workflow
  • targets dotnet standard
  • Fully async
  • About 350 lines of unit-tested, commented code.

Usage

using(var server = new HttpServer("C:\path\to\webroot\", "localhost", 8080, enableAutorefresh: false))
{
 server.Start(CancellationToken.None); // or a cancellation token, if you require cancellation
 Console.ReadKey("server started");
} // server will end when it is disposed or the cancellation token is triggered

If you're using the autorefresh (i.e. "live reload"), call server.SendClientRefresh() to trigger a browser refresh. This is most often called in an event handler, like FileSystemWatcher.Changed.

Installing

Right now there's no nuget package; if you want one, open a GitHub issue and I'll create a package!

Development

  • HttpServer: the main user entry point. Its responsibility is managing the .NET HttpListener API
  • RequestHandler: maps an http request to an http response
  • HttpServerResponse: a model of an http response, contains some static functions to create common response types, like static files or 404 errors.

About

Development server suitable for embedding in dotnet / corert applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /