r/PowerShell • • Feb 04 '20

Pode - PowerShell Web Server

I've been meaning to post about this on here for a while, so thought a new release would be a good time!

Pode is a cross-platform pure PowerShell Web Server - even HTTPS. There's also support for template engines in views, and even Azure Functions and AWS Lambda support.

Pode lets you build fully custom REST APIs and Websites, with support for Routing, Middleware, Sessions, CSRF, Authentication, and even Web Sockets.

You can run Pode on Windows or Linux, as a Windows/Linux service, in a Docker container, or even on a Raspberry Pi!

The latest release, v1.5.0, now adds OpenAPI and Swagger/ReDoc support.

You can find Pode on [Github] with a full list of features, and the documentation here.

I know some people frown at the idea of PowerShell as a Web Server, but for DevOps Automation and Dashboards it can be quite a useful tool to have! :)

116 Upvotes

30 comments sorted by

View all comments

3

u/SupremeDictatorPaul Feb 05 '20

Very cool. I wrote a multi threaded web server in PowerShell (PEWebServer) around 2 years ago. I took inspiration from Polaris and PSWebServer, and I’m sad I couldn’t pull some from yours.

Mine was for the very niche case of running in Windows PE. For some reason, http.sys says it’s not licensed for WinPE, so the HttpListener class is not available. I had to use a a raw TCP socket and built my own HTTP parser/generator to recreate the HttpListener class. Because they weren’t needed, I didn’t implement encryption or authentication (and wow would doing TLS have been insane).

In any case, it’s incredible how useful and flexible a web server written in PowerShell can be.

3

u/Badgerati Feb 05 '20

I know what you mean about creating HttpListener from scratch! Because it doesn't support HTTPS outside of Windows I ended up also have to roll my own eventually - likewise for web sockets as well.

Almost pulled my hair out doing it! But managed to throw together a server with socket helpers. It was an experience that's for sure, haha!

2

u/SupremeDictatorPaul Feb 05 '20

Quick question, you allow $newLine = "\n"` in the headers, but the HTTP/1.1 specs (rfc2616) section 3.7.1 states:

a bare CR or LF MUST NOT be substituted for CRLF within any of the HTTP control structures (such as header fields and multipart boundaries).

Do you ever see a bare newline used with HTTP/1.1 (out of spec), or are you accounting for other protocol/HTTP versions?

2

u/Badgerati Feb 05 '20

Yes, I did! When I went to test on *nix some of the requests ended with bare newlines. This might have been an HTTP/2.0 thing, but I didn't check at the time.