and I'm trying to merge the two so that I have a server that hosts a html file and also handles requests, the thing is I can't put both actix 2.0 and actix 0.7.19 in my dependencies. Actix 2.0 misses somethings that are in actix 0.7.19 and 0.7.19 misses the things needed from 2.0. Any suggestions?
Hi what should I put for the "path_to_file" if my "index.html" is inside a folder called "main_page"? Also it seems my css and javascript associated with the file doesn't run with "index.html" - what can I do to fix this issue? Thank you for all your help.
Edit: Figured out the pathing, for some reason it didn't work the first time.
The path should be relative to where you called cargo run. As for css and Javascript, those are fetched via separate web calls, so you must have endpoints for those files too.
Hi Alice,
my main_page folder is located right next to the src folder and I cargo run just outside both main_page and src. Under these conditions what should my path be? Also I'm not sure what you mean by endpoints. I had it so that the html file calls upon .css and .javascript.
Edit: Figured out the pathing, for some reason it didn't work the first time.
Sorry, could someone explain why my css and javascript stopped getting called when I call on the html file as drewkett showed? It used to be fine in the previous way of hosting index.html.
Your original code was probably sharing the whole folder "main_page", so it was automatically handling serving the css files as well. To replicate that, it looks like instead you'll need to do the following
use actix_files::fs;
App::new()
.route("/", web::get().to(index))
.route("/again", web::get().to(index2))
.service(fs::Files::new("/app", ".").show_files_listing())
or the following if you still have the ./main_page/ folder
use actix_files::fs;
App::new()
.route("/", web::get().to(index))
.route("/again", web::get().to(index2))
.service(fs::Files::new("/app", "./main_page").show_files_listing())
Edit:
This information can also be found in the original link i shared, just so you know where to find it in the future.
Hi drew, thanks for all your help - one question though, what route do I head into to see it open the files? I tried localhost:8088/app but it doesn't seem to work.