text: from django import forms
  import json
  import os
  import requests
  from . import constant
  
  class PiCameraForm(forms.Form):
      FORMATS = (('jpeg', 'jpeg'), ('png', 'png'))
      image_format = forms.fields.ChoiceField(
          label='Image format',
          choices=FORMATS,
          initial=['jpeg'],
          required=True,
          widget=forms.widgets.Select(attrs={'class': 'form-control'}),
      )
      send_slack = forms.BooleanField(
          label='Send to slack',
          required=False,
          widget=forms.CheckboxInput(attrs={'class': 'check', 'data-toggle': 'toggle'}),
      )
  
      def get_image(self):
          http_host = os.getenv('HTTP_SERVER_HOST')
          http_port = os.getenv('HTTP_SERVER_PORT')
          image_format = self.cleaned_data['image_format']
          send_slack = self.cleaned_data['send_slack']
          url = 'http://{}:{}/web-camera/'.format(http_host, http_port)
          response = requests.post(url, json={'format': image_format, 'send_to_slack': send_slack})
  
          if response.status_code == 200:
              data = response.json()
              ret = {'img': data['message'], 'scale': '100%'}
          else:
              ret = {'img': constant.NO_IMAGE_BASE64, 'scale': constant.NO_IMAGE_SCALE}
  
          return ret
  