https://github.com/waf/devserver
Development server suitable for embedding in dotnet / corert applications.
https://github.com/waf/devserver
corert dev-server developer-tools http-server
Last synced: 3 months ago
JSON representation
Development server suitable for embedding in dotnet / corert applications.
- Host: GitHub
- URL: https://github.com/waf/devserver
- Owner: waf
- Created: 2018-11-25T16:01:37.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-25T16:02:04.000Z (about 7 years ago)
- Last Synced: 2025-07-08T10:48:33.825Z (7 months ago)
- Topics: corert, dev-server, developer-tools, http-server
- Language: C#
- Homepage:
- Size: 14.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://github.com/aspnet/Home/issues/3079).
- 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
```csharp
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.