Ask coding questions

← Back to all posts
Mixing languages in one repl
iiap623616 (2)

I was wondering if it is possible to run more than one language in one and the same repl.
For example, I would like to generate an html+javascript page using Python, and then be able to run that page just like I do in an HTML repl.
If I create a Python repl for example, there is no way to run the HTML file - even if I have it in that repl.
Thank you in advance for the clarification.

Answered by mat1 (4399) [earned 5 cycles]
View Answer
mat1 (4399)

You can use Flask to create web servers using Python.
Flask's official documentation is here but you could also look at my quick example at
Please upvote this comment if it was helpful or useful in any way

iiap623616 (2)

@mat1 This will likely be my next step. But for now I am looking for a way to just do that -- generate an HTML file and then open it in a browser. Ideally, I would have everything in one environment (like a directory), all of it being online (not having to install anything locally).
Thank you!

XavierDD (91)

@iiap623616 with flask you can generate your file then use

from flask import Flask, render_template
app = Flask(__name__)
def render_static(page_name):
    return render_template('%s.html' % page_name)
if __name__ == '__main__':
    #Html stuff generator.
iiap623616 (2)

@mat1 Yes, thank you! I got it to work - thanks to your example!
One confusing part was the "" file, but now it works!

pyelias (2462)

If you specifically want to create html+js in Python, you can use a framework like Flask or Django to create a webserver.

HappyFakeboulde (237)

You could pick the language of the script that starts the whole thing and then put other programs from other languages in the repl which are run by the main file