Skip to content

Commit

Permalink
add 404 code
Browse files Browse the repository at this point in the history
  • Loading branch information
steve02081504 committed Mar 18, 2024
1 parent 7af0afa commit 200f400
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/WebServer/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ function HandleRequest($context) {
$body = Get-Content -LiteralPath "$PSScriptRoot/index.html" -Encoding utf8 -Raw
$buffer = [System.Text.Encoding]::UTF8.GetBytes($body)
}
default {
$context.Response.StatusCode = 404
$context.Response.ContentType = "text/plain"
$buffer = [System.Text.Encoding]::UTF8.GetBytes('Not Found')
}
}
$context.Response.ContentLength64 = $buffer.Length
if ($buffer) {
Expand Down

0 comments on commit 200f400

Please sign in to comment.