Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
7d62d89f
"ppocr/git@developer.sourcefind.cn:wangsen/paddle_dbnet.git" did not exist on "18669cc344a872a1e1f985c79b82c43ffccf00bf"
Commit
7d62d89f
authored
Apr 05, 2023
by
EllangoK
Browse files
add cors middleware
parent
349f15ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
server.py
server.py
+14
-1
No files found.
server.py
View file @
7d62d89f
...
...
@@ -27,6 +27,19 @@ async def cache_control(request: web.Request, handler):
response
.
headers
.
setdefault
(
'Cache-Control'
,
'no-cache'
)
return
response
@
web
.
middleware
async
def
cors_middleware
(
request
:
web
.
Request
,
handler
):
if
request
.
method
==
"OPTIONS"
:
# Pre-flight request. Reply successfully:
response
=
web
.
Response
()
else
:
response
=
await
handler
(
request
)
response
.
headers
[
'Access-Control-Allow-Origin'
]
=
'*'
response
.
headers
[
'Access-Control-Allow-Methods'
]
=
'POST, GET, DELETE, PUT, OPTIONS'
response
.
headers
[
'Access-Control-Allow-Headers'
]
=
'Content-Type, Authorization'
response
.
headers
[
'Access-Control-Allow-Credentials'
]
=
'true'
return
response
class
PromptServer
():
def
__init__
(
self
,
loop
):
PromptServer
.
instance
=
self
...
...
@@ -37,7 +50,7 @@ class PromptServer():
self
.
loop
=
loop
self
.
messages
=
asyncio
.
Queue
()
self
.
number
=
0
self
.
app
=
web
.
Application
(
client_max_size
=
20971520
,
middlewares
=
[
cache_control
])
self
.
app
=
web
.
Application
(
client_max_size
=
20971520
,
middlewares
=
[
cache_control
,
cors_middleware
])
self
.
sockets
=
dict
()
self
.
web_root
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"web"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment