https://github.com/rmiguelkelly/winserver
C# HTTP server using asynchronous sockets which allows for local small web hosting.
https://github.com/rmiguelkelly/winserver
Last synced: 3 months ago
JSON representation
C# HTTP server using asynchronous sockets which allows for local small web hosting.
- Host: GitHub
- URL: https://github.com/rmiguelkelly/winserver
- Owner: rmiguelkelly
- Created: 2018-07-30T22:22:15.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-31T18:00:00.000Z (about 7 years ago)
- Last Synced: 2025-03-27T04:17:09.446Z (7 months ago)
- Language: C#
- Size: 27.3 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WinServer
C# HTTP server using asynchronous sockets which allows for local small web hosting.## Set Up
#### Make an instance of the **WinServer** class
#### *WinServer* myServer = new *WinServer();*## Make a Callback Function
###### Once an HTTP request is recieved, a callback function will be invoked
#### myServer.RunServer(*8080*, (req, res) => {
#### *res.Body = "hello world"*;
#### });## Test it Out!
#### Go to any webbrowser on your machine and type in *127.0.0.1:8080*
#### You should see *hello world* pop up in plain text format## Additional
### HTML Response
#### For an HTML body
#### myServer.RunServer(*8080*, (req, res) => {
#### *res.Headers.Add("Content-Type", "text/html");*
#### *res.Body = "\hello world\
";*;
#### });### Read URL Parameters
#### To read values passed through the URL *ie* www.example.com/id=17
#### myServer.RunServer(*8080*, (req, res) => {
#### *if (req.Parameters.Count > 0)* (always good to check)
#### *res.Body = req.Parameters["id"];*
#### });