Hosting Image Files (for self-hosted webpages) in Agent

I’ve been toying with hosting webpages directly from an Agent and one issue I came across was how to store/serve image assets. (Text files like HTML and JavaScript are pretty straightforward through Squirrel verbatim strings and using two double quotes to escape all " characters).

Anyway, I came up with the idea to store the image as a Base64 encoded string. Attached is a working example for anyone that is curious. You can use somewhere like
to get the Base64 encoded string to paste into your agent.

Wow that is awesome! I never really thought about using the agent for that. Eliminates the need for an app on your phone! Thank you!

We’ve done a few projects that host webpages out of agents. Take a look at our SnackBot agents code for a good starting place :slight_smile:

We don’t store images as base64 encoded strings (that’s quite clever though) - we try to find images that are creative commons, and just link to those.

deldrid1 Excellent idea, thanks for sharing that. I was wondering whether something like this was possible, fully self contained web page and assets from an agent. Excited to try this out.

… which now leads me to ask, is there a size restriction for an Agent (or restrictions, file size? Lines? Compiled / bytecode size? RAM on the server? etc.)

I’ve tried to use CDN’s for as many things as possible but there are a few things that sometimes you just need custom for a webpage :).

@kcampbell - I know there is a 1mb ram (as returned by imp.getmemoryfree()) limitation and I’d imagine there is also a compiled by bytecode size (which const variables like my image strategy would go toward) but I don’t know how big that is.

The 1MB limit is for the whole agent, and your const variables will be counting towards it.


Good to know, thanks guys!