table_advanced_samples_5.py 794 B

123456789101112131415161718192021
  1. def set_cors_rules(self, table_service):
  2. cors_rule = CorsRule(
  3. allowed_origins=['*'],
  4. allowed_methods=['POST', 'GET'],
  5. allowed_headers=['*'],
  6. exposed_headers=['*'],
  7. max_age_in_seconds=3600)
  8. print('1. Get Cors Rules')
  9. original_cors_rules = table_service.get_table_service_properties().cors
  10. try:
  11. print('2. Overwrite Cors Rules')
  12. table_service.set_table_service_properties(cors=[cors_rule])
  13. finally:
  14. #reverting cors rules back to the original ones
  15. print('3. Revert Cors Rules back the original ones')
  16. table_service.set_table_service_properties(cors=original_cors_rules)
  17. print("CORS sample completed")