1
0

【WebDAV】wsgidavでCORS【Access-Control-Allow-Origin】

Last updated at Posted at 2024-03-14

インストール

pip install wsgidav cheroot

CORS有効化

wget https://gist.github.com/GitHub30/e24acae4248902b24531b3f8ab18630b/raw/wsgidav.json
wsgidav.json
{
  "cors": {
    "allow_origin": "*",
    "allow_methods": "*",
    "allow_headers": "*",
    "expose_headers": "*",
    "allow_credentials": true,
    "max_age": 864000
  }
}

起動

wsgidav --root=. --auth=anonymous

動作確認

// ファイルアップロード
fetch('http://localhost:8080/hello.txt', {method: 'PUT', body: 'hello'})


// ファイルの最終更新日時取得
const response = await fetch('http://localhost:8080/hello.txt', {method: 'PROPFIND'})
console.log(response.ok)
const doc = await response.text().then(xml => new DOMParser().parseFromString(xml, "text/xml"))
const lastModified = new Date(doc.querySelector("getlastmodified").textContent)
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0