Simple web server

This commit is contained in:
Florian Schroedl
2022-05-04 17:00:00 +02:00
parent f038e4f272
commit 05ecdb1f9e
13 changed files with 209 additions and 7 deletions

24
src/server/env.nim Normal file
View File

@@ -0,0 +1,24 @@
import std/[
mimetypes,
os,
]
const PORT_DEFAULT* = 1337
const HTML_ROOT* = "../js"
const DIST_ROOT* = HTML_ROOT.joinPath("dist")
type Env* = ref object
port*: int
mimeTypes*: MimeDb
htmlRoot*: string
distRoot*: string
proc initEnv*(): auto =
Env(
port: PORT_DEFAULT,
mimeTypes: newMimetypes(),
htmlRoot: HTML_ROOT,
distRoot: DIST_ROOT,
)
echo newMimetypes().getMimetype("txt")