def post(self): try: post_manager = PostManager() post_manager.remove_post_image(request.form) return {'message': 'Post Updated'}, 204 except Exception as e: return {'message': 'Something went wrong'}, 500
def delete(self, post_id): try: post_manager = PostManager() post_manager.delete_post(post_id) return {'message': 'Post Deleted'}, 204 except Exception as e: return {'message': 'Something went wrong'}, 500
def put(self): try: post_form = request.form post_manager = PostManager() post_manager.update_post(post_form) return {'message': 'Post Updated'}, 204 except Exception as e: return {'message': 'Something went wrong'}, 500
def post(self): try: post_manager = PostManager() request_file = request.files['file'] if len( request.files) > 0 else None created = post_manager.create_home_post(request_file, request.form) print(created) if created: return {'message': 'Post Created'}, 201 else: return {'message': 'Bad Request -- Duplicate Title!'}, 400 except Exception as e: return {'message': 'Something went wrong'}, 500
def post(self): try: file_list = [ request.files[image_file] for image_file in request.files ] if file_list[0].content_type not in VALID_CONTENT_TYPES: return { 'message': F'File type: "{file_list[0].content_type}" is not accepted. Please upload an image file.' }, 400 post_manager = PostManager() url = post_manager.add_post_images(file_list, request.form) return {'message': 'Post Updated', 'newUrl': url}, 200 except Exception as e: return {'message': 'Something went wrong'}, 500
def get(self, post_location): try: post_manager = PostManager() return post_manager.get_location_posts(post_location), 200 except Exception as e: return {'message', 'Something Went Wrong'}, 500
def get(self, post_title): try: post_manager = PostManager() return post_manager.get_single_post(post_title), 200 except Exception as e: return {'message': 'Something Went Wrong'}, 500
def get(self): try: post_manager = PostManager() return post_manager.get_all_posts(), 200 except Exception as e: return {'message': 'Something Went Wrong'}, 500
def get(self, post_id): try: post_manager = PostManager() return post_manager.get_single_post_admin(post_id), 200 except Exception as e: return {'message': 'Something Went wrong'}, 500