Passing parameters to a Repl via its replit.com URL

Describe your feature request

My most common use of replit is for demonstrating small programs from StackExchange posts, when that can’t be done using TIO or ATO. The problem is, I have to fork a new Repl every single time, even though the Repls are very similar to each other. The differences are so small they could fit easily in URL query parameters.

For example, see my recent answer to Is this a Permutation of 1…n. I have three replit.com links in that post, and they’re all very similar; the only differences are the regex and the command-line parameters to RegexMathEngine.

What problem(s) would this feature solve?

If I could pass parameters via the replit URL, for example like this:

replit.com/@Davidebyzero/Is-this-a-Permutation-of-1-to-n?regex=^%28%3F%2A.%2A%28%3Ax%2A%29x%3A%29%28%28.%2A\1x\b%29{2}|%28%3F!.%2A\1\b%29%29&mode=-xml&inverted=1

And then I could read the parameters via environment variables, then I’d be able to reduce this down to just a very small number of Repls, and it would be much easier to maintain them. (And I’d probably parametrize much more than the mock-up example above does.)

As it is now, each forked Repl has to have its own compiled copy of RegexMathEngine, and if I fix a bug in RegexMathEngine, I have to recompile it on each forked Repl individually if I want them all to benefit from the fix. That’s completely impractical already, given how many forks I have at this point.

Explain what you were trying to do when you came across the problem leading to this feature request

I’ve researched this for many hours, and I could not find any way to do it. Is there some way I missed? If not, I’d really appreciate it if this feature were added.

1 Like

Could you create a repl that runs your program for users and lets users interact with it using its website?

1 Like

That’d pretty much defeat the way in which these links are supposed to work. Clicking on the link in the StackExchange post should take them directly to the particular test that was linked. If I had to ask users to go through a menu to get to the correct test, when the link should have taken them directly there, I think hardly anyone would bother; most would probably just close the repl.

Could the repl run a webserver that lets users run things on the repl from its repl.co website?

Is it possible to run shell programs in a console from inside a repl.co website?

(Basically I mean, just like a repl slug.)

Yes. You could probably create something similar to https://riju.codes/ that lets users just open a webpage with URL parameters (and the server could automatically start the program for the user with the parameters provided and send the output to the user in real time).

3 Likes

Ideally I’d like it to work like https://ato.pxeger.com.

I’m not familiar with https://riju.codes/. Does that run the programs on its own server, or locally on the person’s computer via emscripten emulation or something like that?

1 Like

It runs it on its server (you could probably do something similar)

Because I already tried compiling RegexMathEngine with emscripten, and it was way too slow.

2 Likes

Well, thanks I guess. I suppose I probably will have to end up doing something like that, but I would prefer it if the URL parameter thing were possible in replit.

2 Likes

Hey @Davidebyzero! Welcome to the community!

I don’t think directly passing the parameters would work, since Replit requires a few parameters like v(to tell if the Repl is in view mode or not) in order for the Repl to display the intended content.

However, it could be implemented using a different parameter like repldata (or just data) and store it as a stringed object which can be parsed to be used by the Repl.

3 Likes

Hi @Davidebyzero thanks for your question.

Apologies if I’m misunderstanding your question here but wouldn’t this be possible if you set up a Flask app that took in parameters via the repl.co url?

There is more information about how to do this here: Flask URL Parameters | How Do URL Parameters Work in Flask?

3 Likes

I think he wanted to be able to show the website with different parameters in the replit.com website, so that it could be display in an iframe without having to redirect the user.

But I guess passing parameters through the Repl website would work as well, and may be even better since it doesn’t need to load a lot of files to use the website.

3 Likes

Thanks @savardo I thought I might have misunderstood this question! :laughing:

My only thought about sharing replit.com links would be that the users clicking would be directed to the cover page and that doesn’t automatically run. I’m not suggesting it isn’t possible here, but I’m trying to understand the logic around directing users to this page rather than a website.

2 Likes

I don’t really know, probably because it’s much easier to just let Replit do the hard work rather than creating a website just to show a demonstration.

2 Likes

Thanks @savardo!

Yes indeed, putting all the data in a single URL parameter such as repldata or data would do the job just fine.

And indeed, it seems rather overkill for me to make my own code-running website to do this, when Replit is almost plenty good enough on its own. And I’ll almost certainly eventually be asking the creator of an existing code-running website (ato.pxeger.com) to add my language to their site anyway.

(Also incidentally, not that it’s an important distinction, but these won’t be shown in iframes, just clickable links that open the Repl as its own page.)

2 Likes