Skip to content
← Back to Community
How to use CGI in a web server on Repl
Profile icon
[deleted]

This isn't associated with any specific programming language, although I'm planning to use C++ with CGI, if you care to know.

Is it possible to use CGI on a web server on Repl.it? If so, how? Can anyone set up a basic example? My major problem is that I don't know how to do this on Repl.it, as opposed to my personal computer, although, I've yet to do this at all.

Is this possible using a NodeJS Repl?

I have found a Node JS CGI extension, but it uses JavaScript, so it's not just running an executable. Thus it was as useful as EJS, if not less.

I was going to attempt to eventually create a C++ server, would it be possible to do this without going though an extreme amount of work?

Voters
Profile icon
AnGoose17
Profile icon
programmeruser
Comments
hotnewtop
Profile icon
programmeruser

Hi,
Try using this repl: https://repl.it/@programmeruser/python-cgi-server


@xxpertHacker
did this answer your question?

Profile icon
SixBeeps

I mean, frameworks like Django and other similar frameworks. So... yes?
I haven't done anything like that in C++, and unfortunately there aren't any templates written in it. There are, however, some JS (and Node I believe) templates to choose from.
EDIT: Yes, there are Node templates

Profile icon
[deleted]

@SixBeeps
Does Django allow CGI? which other frameworks allow this?

Profile icon
SixBeeps

@JadenGarcia
Ok, I misread the Wikipedia article and didn't realize it was a specification not an idea.
Django does have some kind of CGI support, but I don't know if it'll work or not. Your only choice is to try it yourself.
C++ has cgicc. Don't know if that's what you need, but it's there.
Any reason why you want to use CGI?

Profile icon
[deleted]

@SixBeeps
Creating a dynamic web page. PHP isn't an option, we need it to be fast and capable of supporting a heavy load, so I was thinking about using C++'s multi-threading.

Profile icon
[deleted]

@SixBeeps
I have an idea of how to code the web page, after doing hours of research, but I am lost as to how to set up a web server capable of supporting this on Repl.

Profile icon
SixBeeps

@JadenGarcia
PHP isn't fast and strong enough?

Profile icon
[deleted]

@SixBeeps
No? Also, I'm more familiar with C++. Eventually I'll attempt to make a whole C++ server, so it's best to keep everything in one language?
You have to agree with keeping as few different languages as possible, right?

Profile icon
SixBeeps

@JadenGarcia
That's fair, but also like baking a cake over a bonfire. Sure, you might be used to building them, but the oven is not hard to learn at all, and you'll find it a heck of a lot more efficient to use something meant for making cakes.
You're not even restricted to using PHP. I mentioned Django (which is a Python framework), but there's also things like Node (haven't used it before, but there's quite a bit of content surrounding it here).

Profile icon
[deleted]

@SixBeeps
I'm familiar with Node, and it has what I need, but I'm looking for lower level control of what my program does. Also, once again speed, Python and JavaScript are both too slow, although I do know that Python can use multiple threads. I'm honestly familiar with Python Node, and PHP to a certain degree.

Profile icon
SixBeeps

@JadenGarcia
TBH if these languages are too slow or not flexible enough, you're doing something wrong. A lot of existing projects are written in them, so I don't see how they are the limiting factor.

Profile icon
[deleted]

@SixBeeps
Okay okay... it's just preference, which is totally subjective.

Profile icon
CSharpIsGud

@JadenGarcia
preference or not, you are REALLY better off using javascript or some other higher-level backend language(maybe one that supports true multithreading?) instead of C++

Also from what im reading on CGI, it can be slower than just doing it without CGI. As the server has to make new processes for the programs

Profile icon
[deleted]

@CSharpIsGud
But I'm already doing so well! Check it out yourself: https://repl.it/@JadenGarcia/CGI.

Profile icon
CSharpIsGud

@JadenGarcia
wew that is some really hard to read C++

I do like what you did with the html though.

and still, if you can do it without cgi you probably should

Profile icon
[deleted]

@CSharpIsGud
Oh yeah, I worked from easily readable to anything but readable. Honestly I need a better way to do the Tag() nesting. I'm in the middle of redesigning it.