Ask coding questions

← Back to all posts
how do you make the main.py run
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
Mantaray06
Comments
hotnewtop
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:

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

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

Mantaray06

@CodingElf66
thank you, that is awesome!

CosmicBear

Use a .replit file maybe.

Mantaray06

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

BuddyRaider

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

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

CodingElf66

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

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

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.

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

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.

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

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.

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.