-
Notifications
You must be signed in to change notification settings - Fork 0
Home
tommyinb edited this page Jun 17, 2016
·
22 revisions
- One Single Executable: SimpleFileServer.exe
- Size: 1.1MB
- Framework: .NET 4.5
It is designed to let web clients use GET/POST/DELETE requests to access files. eg.
- [POST] http://localhost:8892/example1.png
- [GET] http://localhost:8892/example2.txt
- [DELETE] http://localhost:8892/example3.jpg
- Double click "SimpleFileServer.exe".
- Done.
- Put a file in the program directory, eg. put "example.txt".
- Open any browser.
- Goto "http://localhost:8892/example.txt".
- You get your file.
- Open any HTTP tools, eg. Postman.
- Upload your file to url, eg. "http://localhost:8892/example.txt".
- Check your file and it will be in the program directory.
- Design your own upload form.
- Open any HTTP tools, eg. Postman.
- Send a DELETE action to url, eg. "http://localhost:8892/example.txt".
- File is deleted.
- You can also delete through any browser.
- Browse file url with "?delete" parameter, eg. "http://localhost:8892/example2.txt?delete".
- File is deleted.
- Just browse folder url, eg. "http://localhost:8892/folder1".
- Files are listed.
- Adding "?folders" or "?both" parameter lists sub-folders as well.
- Start program with parameter, eg. "SimpleFileServer.exe 8888".
- Browser "http://localhost:8888" to check the new port.
- Start program with second parameter as directory, eg. "SimpleFileServer.exe 8888 folder1".
- Add files into "folder1" folder, eg. add a "example.txt".
- Browser "http://localhost:8888/example.txt" to check the new directory.
Responses = new List<IServerResponse>();
Responses.Add(new DeleteFileResponse(directory));
Responses.Add(new GetFileResponse(directory));
Responses.Add(new PostFileResponse(directory));
Responses.Add(new IndexResponse(directory));
Responses.Add(new DirectoryResponse(directory));
Responses.Add(new BadRequestResponse());
Just add your own code to the collection.
public interface IServerResponse
{
bool IsValid(HttpListenerRequest request);
Task Response(HttpListenerContext context);
}
Simple is the key. Its core bases on only 4 short blog posts - less than 50 lines.
Anyone can read it within 5 minutes.
- http://bookmi.blogspot.hk/2015/01/cweb-server.html
- http://bookmi.blogspot.hk/2015/01/c-web-server-part-2.html
- http://bookmi.blogspot.hk/2015/01/c-web-server-part-3.html
- http://bookmi.blogspot.hk/2015/01/c-web-server-part-4.html
- One Single Executable: SimpleFileServer.exe
- Size: 1.1MB
- Framework: .NET 4.5
- Release Date: 2016/04/18