[Python] Is it possible to have the backend of a website written in python such that I can...

Discussão em 'Python' iniciado por Stack, Fevereiro 21, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to create a website that is centered on an algorithm I developed in Python. My vision is that the user would enter something and then receive the output which has been generated with Python. I am also trying to call a Python file because the amount of Python code that I need to implement is huge.

    For simplicity's sake, how would I implement this Python file into a website with typing spaces:

    math.py


    def calc(a, b):
    c = a + b
    return c


    I tried to understand brython and I used their provided example, but it did not work:

    index.html


    <html>
    <script src="https://raw.githack.com/brython-dev/brython/master/www/src/brython.js"></script>
    <script src="https://raw.githack.com/brython-dev/brython/master/www/src/brython_stdlib.js"></script>

    <body onload="brython()">
    <input type="text" id="text" placeholder="Enter anything in mind">
    <span id="output"></span>
    <script src="C:\ExampleCode\example.py"
    type="text/python" id="script1"></script>
    </body>
    </html>

    example.py (I also tried ".bry")


    from browser import document

    def show_text(e):
    document['output'].textContent = e.target.value;

    document['text'].bind('input', show_text)

    Continue reading...

Compartilhe esta Página