Issue
I have developed a Flask project, that uses Waitress for production. I have followed this link
The thing is that I don't want to send all the project to the production server. I mean, as an example production in Java, I make .war of the project and run on the Tomcat server.
How can I do this in Python with Flask?
Solution
Python is an interpreted language, so there is no need to "build" your code. The reason Java includes a build step is that Java requires compilation. At high level, all you do is put your Python code on a server, installing any pip requirements, and telling Apache/Nginx where to find your code and how to run it.
If you have complex Javascript as part of your code, you may very well have a build step for the Javascript, such as using babel and webpack. But that should be entirely separate from getting the Python side to work.
If you want to protect your code for some reason, you can do that with a code obfuscation or by just deploying the pyc files, but all of these are complex techniques that you should only do if deploying to untrusted servers. See this article for some examples.
As an aside, Flask has a guide for how to configure it with mod_wsgi and Apache: https://flask.palletsprojects.com/en/1.1.x/deploying/mod_wsgi/
Answered By - Zags
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.