예제 #1
0
 def __call__(self, request):
     if request['method'] == 'POST':
         data = request['data']
         title = data['title']
         text = data['text']
         email = data['email']
         print(
             f'Нам пришло сообщение от {email} с темой {title} и текстом {text}'
         )
         return '200 OK', render('contact.html')
     else:
         return '200 OK', render('contact.html')
예제 #2
0
 def __call__(self, request):
     if request['method'] == 'POST':
         data = request['data']
         name = data['name']
         category_id = data.get('category_id')
         print(category_id)
         category = None
         if category_id:
             category = site.find_category_by_id(int(category_id))
             course = site.create_course('record', name, category)
             site.courses.append(course)
         return '200 OK', render('create_course.html')
     else:
         categories = site.categories
         return '200 OK', render('create_course.html',
                                 categories=categories)
예제 #3
0
 def render_template_with_context(self):
     template_name = self.get_template()
     context = self.get_context_data()
     logger.log(template_name)
     return '200 OK', render(template_name, **context)
예제 #4
0
 def __call__(self, request):
     secret = request.get('secret_key', None)
     print(secret)
     return '200 OK', render('index.html', objects_list=site.courses)