Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

284
Vistas
Changing Flask app's config variables during app runtime?

So I have a flask app running and this is how the config file looks like:

class config(object):
    SECRET_KEY = 'india'

class configTest(config):
   MYSQL_HOST = 'host1'
    MYSQL_PORT = 3306
    MYSQL_USER = 'admin'
    MYSQL_PASSWORD = 'yangmai'
    MYSQL_DB = 'ide'

class configProd(config):
    MYSQL_HOST = 'host2'
    MYSQL_PORT = 3306
    MYSQL_USER = 'admin'
    MYSQL_PASSWORD = 'yangmai'
    MYSQL_DB = 'ide'

In my init.py, I do this:

app.config.from_object('project.config.configTest')

Works good. Now what I want is to give user the option to switch the db at the time of logging in. So essentially, the config class should change from configTest to configProd or vice versa as the user selects.

The idea is to give user the option to access the test and prod environments without deploying two separate apps. Any solutions? Also, the app is run by apache.

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda