Actix is serving only your form, not your scripts and style sheets. You have to serve those as well (probably the whole contents of the codemirror directory). I'd recommend using the actix-files crate for serving static files and directories. I think adding a Files service that serves your codemirror directory should do the trick:
(I'd also use actix-files to serve your html form as well, see i.e. NamedFile or this section of the actix documentation)
As far as I understood OPs problem, these stylesheets are not loaded when the form (which works fine I assume from the screenshot) is loaded with actix. When the form is opened via file://path/to/form, the style is loaded correctly, resulting in the styled version of the same form that can be seen in the second screenshot.
Hmm, could you try removing the leading dot from the path? Convert the path from the relative ./t to the absolute /t? I'm unsure whether actix serves a relative mounting point as expected or whether it will be served at localhost:8081/./t. Also, what do you see when you open localhost:8081/t in your browser? You should see the contents of your templates directory.
P.S.: Just a sanity check, but you are running your web server from the root directory of your my_crate crate, right? Not something like cargo run --manifest-path my_crate/Cargo.toml from the directory with my_crate and templates in it?
As the screenshot shows, the first noting place must be ./templates, but the second noting place must be ../templates. It seems that async fn main runs in ./my_crate, but async fn show_html runs in ./my_crate/src.
After I changed to that, everything works fine.
Well, no, all your code runs in the same working directory. The include_str! macro works differently. include_str! knows nothing about your working directory, as it is executed at compile time, including the file as an UTF-8 string. It therefore includes a file relative to the file where include_str! is called:
The file is located relative to the current file (similarly to how modules are found).
Since you call include_str! from src/main.rs it will look for the file to include relative from the src/ directory. Unlike Actix which does look up your files at run time relative to your working directory.