-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[question] Simple server like five-server-vscode
#103
Comments
Here is an idea to get started (using my own mummy-utility, you can just copy-paste the sendFile) mummy_folder
- mummy_server.nim
- files
- image.jpg # mummy_server.nim
import mummy, mummy/routers
import mummy_utils # https://github.com/ThomasTJdev/mummy_utils
proc serveFiles(request: Request, details: Details) =
sendFile("files/" & @"filename")
var router: Router
router.routerSet(HttpGet, "/files/images/@filename", serveFiles)
let server = newServer(router)
echo "Serving on http://localhost:8080"
server.serve(Port(8080)) curl localhost:8080/files/images/image.jpg |
@ThomasTJdev tysm! |
You can make a redirect on the proc redirectUno(request: Request) =
if request.uri == "/":
# request.respond(200, @[("Content-Type", newMimetypes().getMimetype(path.split(".")[^1]))], fileBody)
sendFile("index.html")
else:
echo "something else"
proc redirectDuo(request: Request) =
if request.uri == "/":
# request.respond(303, @[("Location", "index.html")])
redirect("/index.html")
else:
echo "something else" |
Published the current effort on @heysokam/mummyd. |
Hi there
I'm trying to create a simple localdev server similar to
nimhttpd
, but usingmummy
.The goal is to create something similar to https://marketplace.visualstudio.com/items?itemName=yandeu.five-server
I have no experience at all creating an http server, so looking for some guidance.
The text was updated successfully, but these errors were encountered: