[Python] Python script prints results on HTML surface

Discussão em 'Python' iniciado por Stack, Julho 10, 2025.

  1. Stack

    Stack Membro Participativo

    I've written a very simple chatbot in Python. It works like if you write something in, it does the Python-based calculations and gives back an answer. Because it checks your previous answers as well, the python script needs to run continuously. I'd like to put the chatbot online, and:

    1. Send the input from the HTML surface back to the server as the source for the raw_input()
    2. Then send back the Python output to the frontend as an answer and as a newline on the chat in the browser in HTML.

    My Python code is:

    def conversation(question):
    answer = #... ... ...(doesnt matter right now)

    print "CHATBOT: " + answer
    next_question = raw_input("YOU: ")
    return next_question

    #==========================
    #INTRO & CALLING FUNTCTIONS
    #==========================
    print "Hi, my name is CHATBOT!"

    #Starts with user input.
    question = ""
    question = raw_input("You: ")

    #calling the conversation function
    question = conversation(question)


    The question is: how can I connect the Python script with my website? How can users interact with my script from a website as I do on my Terminal?

    I'm pretty sure it's very easy, but I have no idea where to start... THANKS!

    Continue reading...

Compartilhe esta Página