tryphotino / photino.NET

https://tryphotino.io
Apache License 2.0
833 stars 68 forks source link

use embedded resources instead of wwwroot #194

Closed kgsensei closed 1 day ago

kgsensei commented 5 days ago

I'm checking out this project and it looks perfect for what I need, but I want to know if it's possible to load files from embedded resources instead of just from the /wwwroot directory? I haven't actually used photino yet, so I apologize if this is obvious or redundant.

Slluxx commented 2 days ago

I would like to know this too. Its pretty much a deal breaker and any other solution i have looked at (Ultralight, Molybden, etc etc) all use external resources, which is against my idea of a portable app.

Edit: I found #97 and tried the react code but it is now creating an empty folder wherever the binary is executed. Photino.Native.dll and WebView2Loader.dll are also still not bundled with the binary. If this feature really works, the templates are outdated. Or maybe it doesnt fully work, i am not sure.

CypherPotato commented 1 day ago

It's not impossible, you can embed the content in your assembly and serve the files with an HTTP server built into the application where your Photino is, and listen to the server that is serving these files directly from the assembly. Photino already has it's own HTTP server, but I made an example using Sisk to serve that static content.

You can view the example I made here.

Basically, you copy the reading stream from Assembly.GetManifestResourceStream to the output of the HTTP response. The example is very basic, it was poorly tested and I only included some supported MIME types. You must adjust according to your needs.

Also, pay attention to the .csproj to correctly embed your resources via:

<ItemGroup>
    <EmbeddedResource Include="wwwroot\**\*" />
</ItemGroup>
kgsensei commented 1 day ago

Ah, thank you.

Slluxx commented 21 minutes ago

As per mentioned issue and templates, it should already be possible without any modifications because it already includes a static file server. The solution here is not to reinvent the wheel but to use and or fix what is already included with photino.

But now, since this issue got closed without getting a proper answer/solution, it will go under.