Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CSRFProtect to flask #2488

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions deeplake/requirements/common.txt
Expand Up @@ -15,6 +15,7 @@ av>=8.1.0; python_version >= '3.7' or sys_platform != 'win32'
pydicom
IPython
flask
Flask-WTF
pyjwt
laspy
nibabel
Expand Down
4 changes: 4 additions & 0 deletions deeplake/visualizer/video_streaming.py
Expand Up @@ -2,6 +2,8 @@

from typing import Optional, Callable, Tuple
from flask import Flask, request, Response
from flask_wtf import CSRFProtect

from deeplake.core.meta.encode.chunk_id import ChunkIdEncoder
from deeplake.core.storage import StorageProvider
from deeplake.core.meta.encode.byte_positions import BytePositionsEncoder
Expand Down Expand Up @@ -175,6 +177,8 @@ def _stop_server():


_APP = Flask("video_stream")
csrf = CSRFProtect()
csrf.init_app(_APP)


@_APP.after_request
Expand Down
4 changes: 4 additions & 0 deletions deeplake/visualizer/visualizer.py
Expand Up @@ -2,6 +2,8 @@
from typing import Dict, Optional, Union
import uuid
from flask import Flask, request, Response
from flask_wtf import CSRFProtect

from deeplake.core.link_creds import LinkCreds # type: ignore
from deeplake.core.storage import StorageProvider
from deeplake.core.storage.s3 import S3Provider
Expand All @@ -20,6 +22,8 @@

_SERVER_THREAD: Optional[threading.Thread] = None
_APP = Flask("dataset_visualizer")
csrf = CSRFProtect()
csrf.init_app(_APP)

log = logging.getLogger("werkzeug")
log.setLevel(logging.ERROR)
Expand Down