Running simple-http-server crate from toy rust program

Hi,

I was wondering if its possible to start and run simple-http-server from within my program. I did add the simple-http-server as my dependency in my cargo.toml, however I dont know if its possible to start the server within my program. thank you for any help, or if you have other library recommendation that I can do what I am looking for.

[dependencies]
simple-http-server = "0.6.8"

Perhaps you should have a look at tiny- http?

thanks! I will do that

Any ideas or examples I can use, how I can serve static contents like html, js, images, fonts etc. The examples in tiny-http are not really helpful to give a good starting point on building a http server to serve static contents.

simple-http-server is a binary meant to be used from the command line, and it serves static content. It is not a library to be added to your program.

tiny-http is a library that you can use to serve anything, including static content, but you have to do all the work yourself.

Your original question did not state what you wanted to do.

There may be other rust http libraries that can serve static content, I don't know, sorry.

You can check the documentation for any of the many other web frameworks: https://www.arewewebyet.org/

Thanks! I used Axum

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.