Connect a Python LLM to an HTML space

I am currently working on a website template created by myself, but I want it to work with a python file that contains backend code to run llms. I am new working with NLP and LLMs, and I am very confused on what to do. How can I connect the python file so that it works with my HTML code?