Skip to content
← Back to Community
how do you make the main.py run
Profile icon
Mantaray06

I made a php web server repl to make a game (similar to mrush.net) and I took some programming from my friends repl where we tried to make it and I feel we failed but he did better than I could have. So I put in a main.py but it is on a php repl and it won't run. How do I make it work. I don't know python and I prefer not to use it on repl because it runs slow on repl.

Answered by CodingElf66 [earned 5 cycles]
View Answer
Voters
Profile icon
HamadAjmi
Profile icon
Mantaray06
Comments
hotnewtop
Profile icon
CodingElf66

There is actually a way to do it!

If you create a PHP web server, you can then create a .replit file. Inside, attach the following code:

run = "main.py"

Then, in your main.py file, just put something in!

Now you can mark it as answered, thanks so much!

Profile icon
Mantaray06

@CodingElf66
thank you, that is awesome!

Profile icon
CosmicBear

Use a .replit file maybe.

Profile icon
Mantaray06

@CosmicBear
I don't understand. Do I change the main.py to main.replit or what.

Profile icon
BuddyRaider

@CodingElf66's answer was on the right track, but rather than

run="main.py"

You need to specify to run "main.py" with "python" as a Python file is not a standalone application:

run="python main.py"
Profile icon
CodingElf66

@BuddyRaider That's for only the Shell I think.

Profile icon
BuddyRaider

@CodingElf66 have you tried it? It gives an error with just "main.py", but it runs fine with "python main.py"

edit: this is the link to the replit docs for .replit files: Replit Docs - Configuring the Run button

Profile icon
SixBeeps

So you want to host your server from that Python file instead of in PHP? Is there a reason why you don't want to make a new Repl for it?

Also, here's how to use the .replit file.

Profile icon
Mantaray06

@SixBeeps
because I don't know Python but my friend already started on the game in python. So I am continuing the work but I can only do so in php, html, and css. But I don't know how to add the already started game into my repl to finish it

Profile icon
SixBeeps

@Mantaray06 If the project was started in one language, you can't just continue it in another. That's not how that works.

Either learn Python or have your friend port the code over to PHP.

Profile icon
Mantaray06

@SixBeeps
thank you, and yes I asked him he told me the same thing. He also told me some ways that it COULD be done but it would be so much easier to just translate the python to php as close as you can

Profile icon
Mantaray06

@SixBeeps
"I mean you could theoretically make a workaround, but it wouldnt be easy by any means" these are his exact words.

I think I will just ask around for someone who is willing to help me make this game.

Profile icon
SixBeeps

@Mantaray06 I know what he's talking about. That's dark magic. I've touched it before, and I never want to touch it again.