Search code examples
javascriptpythonhtmldjango

Is it possible to integrate python with CSS, Javascript, and HTML?


I have a frontend web application built with JavaScript, HTML, and CSS. I would like to incorporate the output of a Python script into my frontend without using a server or a full backend solution.

The Python script is a simple neural network, and I want to display its output in the frontend, such as showing the result as a header or plotting a graph generated by the script.

I have already tried printing the output to the console from the Python script, but I need assistance with transferring that output to the frontend.

Is it possible to achieve this without a server? I am open to suggestions and starting with a simpler solution, like plotting a graph generated by the Python script in the frontend.

I appreciate any guidance or code examples on how to accomplish this. Thank you!

I have looked into Django but I feel as if that seems too complex and more server focused for the simple task I require.

! ANSWERED ! It only lets me accept one answer but I would say that both the streamlit and the Wasm Answers are acceptable.


Solution

  • If you want to incorporate the output of a Python script into your frontend without using a server or a full backend solution, you have a few options available. One approach is to use a technique called "WebAssembly" (Wasm) to run the Python script directly in the browser. Emscripten: https://emscripten.org/ Pyodide: https://github.com/pyodide/pyodide