Code Example

Store parameters as JSON in Configly

Through Configly's intuitive web app you can store and update arbitrary JSON. The JSON is interpreted into native data structures by the client libraries.

# Python / Flask endpoint example
import configly
configly.api_key = 'Dem0apiKEY'

@app.route('/currency_conversion')
def currency_conversion():
  config = configly.get('currency_conversion_parameters')

  # If the conversion isn't specified, get the default from configly
  currency_from = request.args.get('from') or config['default_from']
  currency_to = request.args.get('to') or config['default_to']

  # Fetch the rates from an API
  rates = get_rates(currency_from, currency_to)

  amount = float(request.args.get('amount'))
  converted_amount = rates.get(currency_to) * amount

  return f'{amount:.2f} {currency_from} = {converted_amount:.2f} {currency_to}'

In this example, we built a Flask endpoint to convert an amount in one currency to another.

Several parameters are stored in Configly including an external API URL, default currencies for conversion, and a timeout value.

These parameters can be changed and tuned in moments by simply updating them in Configly. No deploy is needed