There's no need to embed your python scripts anywhere (or to use any javascript/AJAX, as some of the comments suggest).  The simplest way to do "step 3" is as follows:

When the "Compress"/"Merge" button (or link) is pressed, send a request to the server.  Typically you'd use the URL to indicate which action(s) to perform.

When the server receives the above request, generate the corresponding output file.  Any scripts that are installed on the server can be used to help make this file.  That said, I would recommend against writing separate scripts for each task.  Better would be to simply include the processing functions in your django application so the server can call them directly, without having to go through a command-line interface.  Or, if the functions would also be useful outside the context of a web server, they can be moved into their own general-purpose package.

Save the generated file to the database.  This isn't necessary if the server will always run on just one machine, but it's still a good idea if for no other reason than making your code more future-proof.

Create a URL that will serve the generated output file to the client.

Present the user with a download link to the aforementioned URL.


In short, do all the processing on the server.

You may already be aware of this, but one concern with sqlite is that it does not allow more than one process to access the database at a time (roughly speaking).  So if there's any possibility that two people will be using your website simultaneously, don't assume that sqlite will be sufficient.
I am quite new to web application development (Django). However, I have a bit of experience in working with html, css, and  python.
I am developing an application where the user will upload documents as input and change the available parameters values and the application will generate a new document as a downloadable file. (Text editor: VS Code).
(To get an intuition, consider the online pdf resizing applications as an example).
I am building the application from scratch. The major issue is modifying the inputs and producing desired output.
My approach towards it is:

Create python scripts for the different major actions( As per our example case, create pdf_compression.py, merge_two_pdfs.py and so on).
Ask the user to upload the required documents. Store the docs uploaded (only temporarily) and use them for further operations (with assumption that default sqlite3 will be sufficient).
In the webpage, add a button or a link (e.g. "Compress", "Merge") and embed the python script created in step1 (paste the script or add a link to its file location). That will perform the specific task when the button is pressed and generate the output.
Download the generated document.

I have achieved till the step 2 in my task but am lost on how to achieve the "3rd" step. How should I proceed  ahead?
Any suggestions( with code examples) are highly appreciated. I am open to any different approach also.
Update
About the application
The application does not need to serve users globally like google. It will be hosted through a server locally( or though an institutions' local server) and users having access to the server will be accessing it.(in other words it does not need to be https://www... It only needs to be http://ip_address/url.)
Thanks in advance.
Add a custom button/ tag and control its function using a python script in Django web application