Note: I'm new to information security practices so feel free to point out anything I could be doing better.
Situation: I'm creating a web application that runs a Python program as part of the back end. This file is closed source and must be secured from anyone trying to accesses it without permission.
What is the best way to go about securing this file from being copied or seen while still allowing the web application to send input data to the file and receive the proper outputs from the same file?
Also, I'd like to point out that the service doesn't need "bank-level" security, obviously the more secure the better but currently we only have the resources to allow for security measures that are relatively easy to implement.
My original thought was to install Python on the web server and simply use the interpreter to execute the .py file. I'm assuming this is probably pretty insecure, due to the fact that the actual file is just sitting on the web server for anyone to look at?
Secondly, I thought of using a program (Nuitka or PyInstaller) to convert the Python into an executable then just having the binary on the web server. I'm not entirely sure how much this would increase the difficulty to get the source code but more importantly, my colleagues are concerned that using a third party software to convert confidential code is a security risk in itself. Meaning, the software could potentially make copies of the program and ultimately leak the program in some way that could do harm.
Are either of the above methods sufficient or is there a better way of approaching the security of the source code?