I have a question that I don’t know how to see and at the time I followed a tutorial but I don’t remember how it works or what I should do if I’m not in developer
In my app.py I have the following:
if __name__=='__main__':
app.config.from_object(config['development'])
app.run()
Let’s say this refers to another file that I have config.py where there is this code
config = {
'development': DevelopmentConfig
}
If I want to upload my app to production, should I modify those lines?
This can’t be answered as written because “moving an app to production” is not a Python concept. Whatever it is that you are trying to accomplish, is specific to the exact tools and libraries you are using.
You also haven’t said anything about the infrastructure you’re deploying on - some cloud platform (which?)? Virtual machines of some sort? Something else?
It is a linux hosting with python 3.11
It is irrelevant since what I am asking is the concept of the lines, I understand that if it puts development it is because it is in development and once you upload it to production that part should be changed, at least that is what I understand.
Regarding “moving an app to production” I put it precisely along that line.
I don’t know, but I’m sure that when the app is no longer under development, that part of the code must be modified.
Again: the code you have shown us only has any meaning at all, because of the libraries. So nobody can possibly tell you anything useful about how to do what you want - or even properly understand what you want to do - without starting from the beginning and properly describing the problem. There’s no way, for example, that we can explain to you about what the tutorial said, because we have no way to know which tutorial it was.
“Moving an app to production” does not actually mean anything in code terms, and there is no piece of code that simply means “the code is now in production” by itself. That meaning comes from a library that has much more of its own code, that will do things that are useful “in production” according to how the configuration is changed. The documentation for that library will explain what things will be done differently, and how to change the configuration.
I don’t know if I’m explaining myself incorrectly or what, but hey, I repeat.
I just want to know if there is a way to program when you are developing an application, another when you test and another when you go to production.
From what I’ve read there is, and I think there are different settings depending on the state you’re in with the application.
I just wanted to know if that’s what was in my code or not.
Yes. There are countless ways to do this.
However, you are trying to ask about a specific way that somebody else set up for you, and about the details of how to use that way. We can’t answer that, because you aren’t explaining who the “somebody else” is. The best way to understand is to check with “someone else” directly. For libraries and frameworks, that means reading the documentation.
Perhaps approaching this another way: There is not necessarily any
difference for source code or configuration when developing,
testing, or running software in production. These are also all vague
concepts without distinct meaning on their own, heavily dependent on
the context in which they’re placed.
To give a broad example, for the systems automation communities I’m
involved with, we pride ourselves on our ability to “test like
production” using the exact same code and configuration in testing
so that we can be confident those services will work correctly when
deployed to our servers. Our testing (continuous integration) system
relies on a configuration management and orchestration language for
creating test environments, and we parameterize all our
configuration so that test values can be automatically injected when
changes to software or configs are proposed, allowing reviewers to
observe those changes in action for mock deployments of our
services. Once those changes are approved, the exact same software
and config templates are installed onto our production servers, but
injecting the values we use on those systems (particular allowed
addresses, sensitive data like account credentials, et cetera).