To create a HTTP server in C#, we can use the HttpListener
class, which is available in the System.Net
namespace. Here's an example of how to create a simple HTTP server in C#
:
main.cs3366 chars80 lines
This server listens on http://localhost:8080/
and responds to all incoming requests, printing each request to the console. If the request is a POST and has files attached to it, it saves each file to disk.
To upload a file to this server, you can use curl
or a similar tool. Here's an example using curl
:
148 chars2 lines
This will upload the file located at /path/to/file
to the server.
gistlibby LogSnag