Ask coding questions

← Back to all posts
Run other files besides index.html or main.py
TimothyKeenan (0)

Hey All,

I'm teaching two groups of students virtually. One class is working on HTML and the other class is working on Python. Most of these students are working from Chromebooks, so our best option for coding is to use something like repl.it.

Are there any settings somewhere that allows a user to run other files besides index.html and main.py? I'd love it if these students could create a file specific to our lesson and just run that. Currently, I'm having them copy everything from their lesson file into either index.html (for HTML students) or main.py (for Python students) to test their code. This is such a hassle.

Any tips or suggestions?

Commentshotnewtop
Coder100 (10809)

For index.html, just add a link:

<a href="/second.html">click me</a>

And for main.py, create a .replit file, and put:

run = "python second.py"

Another way:

import os
os.system("python second.py")
Axrevyn (265)

Or you could do what I do...

exec(open("file.py").read())

With file.py obviously being whatever file you need to execute.

Coder100 (10809)

hmm exec is good but iirc there are limitations? @Axrevyn

Coder100 (10809)

you can't do it for index.html, but you can for main.py