Today we will update settings page to view config values.

We update TelegramConfig methods to @classmethod for more convenient. We can call the method directly without a need to create an instance of that class. (Read More)

class TelegramConfig(Config):
  def get_telgram_token(self):
    return self.get(TELEGRAM_BOT_TOKEN_KEY)

  def get_base_url(self):
    token = self.get(TELEGRAM_BOT_TOKEN_KEY)
    return '{}'.format(token)


Add a separator and a form-group to view config values

{% extends "base.html" %}

{% set active_page = "settings" %}

{% block main_content %}
<h1 class="mt-5">Settings</h1>
<form action="" method="post">
  {% if message %}
  <div class="alert alert-{{ message["category"] }} alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
      <span aria-hidden="true">&times;</span>
    <strong>{{ message["title"] }}</strong> {{ message["text"] }}
  {% endif %}
  <div class="form-group">
    <label for="webhook_url">Webhook URL:</label>
    <input type="url" class="form-control" name="webhook_url" id="webhook_url" value="{{ webhook_url_value }}">
  <button type="submit" class="btn btn-primary">Update</button>
  <div class="form-group">
    <label for="telegram_token">Telegram Token:</label>
    <input type="text" class="form-control" name="telegram_token" id="telegram_token" value="{{ telegram_token_value }}">
{% endblock main_content %}


class SettingsPage(Handler):
  def get(self):
    kwargs = {
        'title': 'Settings',
    kwargs['webhook_url_value'] = self.__get_webhook_url()
    kwargs['telegram_token_value'] = TelegramConfig.get_telgram_token()
    self.render_template('settings.html', **kwargs)



Settings Page