Python web app and restfull api's in non editable format

Dear All,

I want to develop application having some part is web application and one part is restful api’s.

i want both in form of non editable (like dll’s in dot net) . so user at which application is deployed should not view or make any change in this code.

(obfuscate is not the option for me).

Then python is the wrong choice for this use case.

Anyone with sufficent motivation can turn the .pyc/.pyo back into a .py - all be it without comments.

Is this really an important requirement for your business idea to succeed?

Is the app that you with to sell really going to be pirated?
Is the app useful in pirated form without support services?

Then your only option - regardless of the language you’re writing it in - is to host it on your own server and grant users access. Fortunately, with web apps, that’s not too difficult.

Fundamentally, if you let people run the code on their own computers, they WILL be able to change it. You can try your hardest to stop them, but unless your app is woefully unsuccessful, there’ll be more users out there than you have developers, so in any kind of arms race, they’re gonna win :slight_smile:

It may seem disheartening at first, but every programmer needs this ego check: Will people REALLY steal my code? Is my code really so much better than the alternatives that people will prefer to make illegal changes to it than to find something else? You might do better, instead, to make it easy (and of course legal) for people to make changes, which would allow your service to be more popular, without needing to spend effort on locking it down. For example, a good plugin architecture can expand the scope of your app without needing you to think of everything yourself, and without compromising your core codebase.

But if you really have to stop people from seeing or changing your code, the only way is for them to never get access to it.

Usually around here we advise folks they don’t really need to hide stuff
as badly as they think they do.

However… you haven’t asked a very specific question, so:

options might include using Cython, possibly PyInstaller, Nuitka
(Nuitka · PyPI - I’d definitely take a look at this one).

Its easy to get the .pyc from pyinstaller. I used to maintain its predecessor meinc installer.
The tech is basically the same, a zip file appened to a .exe stub.

My application is customized for particular organization and the owner have this specific requirement.
As this app is not on internet this will be in local network hosted inside their server. and few peoples need full access of the server, who may modify the app and try to bypass the SOP’s and basic rues/rights for ease of operation. also missuses the application or expose the organization trade secrets to outside world.
is there any possibility of combining python with dot net ?

Sure there is, but if you’re going to put the app on the customer’s server, that just means they’ll need to use both Python and .NET to run it. It won’t change anything about whether they can change the code.

There is no getting away from that. It’s a fundamental.