• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Python SDK)
  4. Static Website Hosting
  5. Viewing Website Hosting Settings

Viewing Website Hosting Settings

You can call ObsClient.getBucketWebsiteConfiguration to view the hosting settings of a bucket. Sample code is as follows:

# Import the module.
from com.obs.client.obs_client import ObsClient
 
# Create an instance of ObsClient.
obsClient = ObsClient(
    access_key_id='*** Provide your Access Key ***',    
    secret_access_key='*** Provide your Secret Key ***',    
    server='yourdomainname'
)
resp = obsClient.getBucketWebsiteConfiguration('bucketname')
 
if resp.status < 300:
    print('requestId:', resp.requestId)
    if resp.body.redirectAllRequestTo:
        print('redirectAllRequestTo.hostName:', resp.body.redirectAllRequestTo.hostName, ',redirectAllRequestTo.protocol:', resp.body.redirectAllRequestTo.protocol)
    if resp.body.indexDocument:
        print('indexDocument.suffix:', resp.body.indexDocument.suffix)
    if resp.body.errorDocument:
        print('errorDocument.key:', resp.body.errorDocument.key)
    if resp.body.routingRules:
        index = 1
        for rout in resp.body.routingRules:
            print('routingRule[', index, ']:')
            index += 1
            print('condition.keyPrefixEquals:', rout.condition.keyPrefixEquals, ',condition.httpErrorCodeReturnedEquals:', rout.condition.httpErrorCodeReturnedEquals)
            print('redirect.protocol:', rout.redirect.protocol, ',redirect.hostName:', rout.redirect.hostName, ',redirect.replaceKeyPrefixWith:', rout.redirect.replaceKeyPrefixWith, ',redirect.replaceKeyWith:', rout.redirect.replaceKeyWith, ',redirect.httpRedirectCode:', rout.redirect.httpRedirectCode)
else:
    print('errorCode:', resp.errorCode)
    print('errorMessage:', resp.errorMessage)