12345678910111213141516171819202122 |
- def set_cors_rules(self, service):
- print('1. Get Cors Rules')
- original_cors_rules = service.get_service_properties()['cors']
- print('2. Overwrite Cors Rules')
- cors_rule = CorsRule(
- allowed_origins=['*'],
- allowed_methods=['POST', 'GET'],
- allowed_headers=['*'],
- exposed_headers=['*'],
- max_age_in_seconds=3600)
- try:
- service.set_service_properties(cors=[cors_rule])
- except Exception as e:
- print(e)
- finally:
- #reverting cors rules back to the original ones
- print('3. Revert Cors Rules back the original ones')
- service.set_service_properties(cors=original_cors_rules)
-
- print("CORS sample completed")
|