Переглянути джерело

Slight fix to file server

master
Roderic Day 5 роки тому
джерело
коміт
0412be6245
1 змінених файлів з 6 додано та 3 видалено
  1. +6
    -3
      pico.py

+ 6
- 3
pico.py Переглянути файл

@@ -19,15 +19,18 @@ class PicoProtocol(websockets.WebSocketServerProtocol):
document = Path(__file__, '..', Path(path).name).resolve()
if not document.is_file():
document = Path(__file__, '..', 'pico.html').resolve()

if document.suffix == '.html':
content_type = 'text/html; charset=utf-8'
elif path.endswith('.js'):
elif document.suffix == '.js':
content_type = 'application/javascript; charset=utf-8'
elif path.endswith('.css'):
elif document.suffix == '.css':
content_type = 'text/css; charset=utf-8'
elif path.endswith('.svg'):
elif document.suffix == '.svg':
content_type = 'image/svg+xml; charset=utf-8'
else:
content_type = 'text/plain; charset=utf-8'

return (
http.HTTPStatus.OK,
[('Content-Type', content_type)],

Завантаження…
Відмінити
Зберегти