Search code examples
stringvariableshosting

Hosting an editable single string of text online?


I'm a twitch streamer and I'm runnig a bot named "Nightbot", which can interact with users in my stream's chat area. They can type a command such as "!hello" and, in response to that, I can tell the nightbot to load up a url, and post the text from that url into the chat.

But the text needs to change each time I play a new game, so the text must be editable. And it can't be a file, because the nightbot expects the url to return just plain text.

So I can't use a file hosting service. Please, don't recommend for me to save a text file to some free hosting service, and put my text into the file.

What I need is a very simple string of texxt that is hosted online, which can be edited, and which can be accessed by a url. Why the literal *eck is that so impossible or unreasonable? I thought we live in 2018.

I spent the entire day trying to learn Heroku, and when that turned out to be unreasonably complicated, I spent some hours trying Microsoft's Azure. Holy moly it turned into connecting storage services, picking price tiers, and do I want that to run on a windows or linux server? And how many gigs of space do I need, and will I be paying by the second? Come on I just need to save an editable string of text online, probably just 100 characters long! Why so difficult!

I guess what I'm looking for is something as easy as tinyurl, but for editable text strings online... just go there and type in the name for my variable, and boom, it gives me a url to update it, and a url to download it. Total time required: less than one minute.


Solution

  • WARNING: both solutions are publicly accessible and thus also editable. You don't want inapproriate text to display on your stream, so keep the link secret. Still there are no guarantees it stays secret.

    Solution 1 (simple and editable via the web UI if you create an account)

    You could just use pastebin.com. Here you can put public/unlisted text.

    When you use the pastebin.com/raw/ + id of your text you get plain text.

    Solution 2 (Bit more complicated, but more advanced)

    You can use JSON Blob This website allows you to host JSON and edit/create/get a string. It has to be valid JSON, but if you use "" around your text it is. Though if you use a curl command to change the text it doesn't have to be valid JSON. Only when you use the website to edit text it has to be.

    First of you create your string and save it. Then you can access the string by doing a GET request on a url like this https://jsonblob.com/api/ + blob id

    Example: https://jsonblob.com/api/758d88a3-5e59-11e8-a54b-2b3610209abd

    To edit your text you have to do a PUT request to the same url, but with the text your want it to change to.

    Example command to change text (I used curl, because that's easy for me):

    curl -i -X "PUT" -d 'This is new text' -H "Content-Type: application/json" -H "Accept: application/json" https://jsonblob.com/api/jsonBlob/758d88a3-5e59-11e8-a54b-2b3610209abd

    You could also use a tool like POSTMAN to do the PUT request.

    For more indepth instruction on how to use JSON Blob you can go to their website: https://jsonblob.com/api