Using HTTP.jl as a static file server #979
phanos-engineer
started this conversation in
Show and tell
Replies: 2 comments
-
|
Related issue: #567 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I couldn't find any information in the documents but I was able to figure out a way to server static files. This allows you to serve a directory as a simple web server.
Assume you have these files to serve
So you have 4 directory depth. You can use
HTTP.serveto serve your pagesusing HTTP,JSON3,Sockets; using Base.Filesystem const ROUTER = HTTP.Router() #four directory deep static stuff being hosted HTTP.register!(ROUTER, "GET", "", static_pages) HTTP.register!(ROUTER, "GET", "/*", static_pages) HTTP.register!(ROUTER, "GET", "/*/*", static_pages) HTTP.register!(ROUTER, "GET", "/*/*/*", static_pages) HTTP.register!(ROUTER, "GET", "/*/*/*/*", static_pages) HTTP.register!(ROUTER, "GET", "/*/*/*/*/*", static_pages) @info "Starting the server" HTTP.serve(ROUTER, Sockets.localhost, 8888 )where the function
static_pagesis defined asThis will work but shouldn't be used for a production level server.
Beta Was this translation helpful? Give feedback.
All reactions