mirror of
https://github.com/EDCD/EDDN.git
synced 2025-04-26 21:22:14 +03:00
Monitor: *Maybe* working now?
It doesn't crash, including when the gateway successfully receives a message, but unclear if those messages are then making it to the Monitor OK.
This commit is contained in:
parent
fdee2c054f
commit
f7370a2f0b
@ -278,31 +278,24 @@ class Monitor(Thread):
|
|||||||
gevent.spawn(monitor_worker, inbound_message)
|
gevent.spawn(monitor_worker, inbound_message)
|
||||||
|
|
||||||
|
|
||||||
class EnableCors(object):
|
def apply_cors() -> None:
|
||||||
"""Enable CORS responses."""
|
"""
|
||||||
|
Apply a CORS handler.
|
||||||
|
|
||||||
name = 'enable_cors'
|
Ref: <https://stackoverflow.com/a/17262900>
|
||||||
api = 2
|
"""
|
||||||
|
response.set_header(
|
||||||
@staticmethod
|
'Access-Control-Allow-Origin',
|
||||||
def apply(self, fn: Callable):
|
'*'
|
||||||
"""
|
)
|
||||||
Apply a CORS handler.
|
response.set_header(
|
||||||
|
'Access-Control-Allow-Methods',
|
||||||
Ref: <https://stackoverflow.com/a/17262900>
|
'GET, POST, PUT, OPTIONS'
|
||||||
"""
|
)
|
||||||
def _enable_cors(*args, **kwargs):
|
response.set_header(
|
||||||
"""Set CORS Headers."""
|
'Access-Control-Allow-Headers',
|
||||||
response.headers['Access-Control-Allow-Origin'] = '*'
|
'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token'
|
||||||
response.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, OPTIONS'
|
)
|
||||||
response.headers['Access-Control-Allow-Headers'] = \
|
|
||||||
'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token'
|
|
||||||
|
|
||||||
if request.method != 'OPTIONS':
|
|
||||||
# actual request; reply with the actual response
|
|
||||||
return fn(*args, **kwargs)
|
|
||||||
|
|
||||||
return _enable_cors
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
"""Handle setting up and running the bottle app."""
|
"""Handle setting up and running the bottle app."""
|
||||||
@ -311,7 +304,7 @@ def main() -> None:
|
|||||||
|
|
||||||
m = Monitor()
|
m = Monitor()
|
||||||
m.start()
|
m.start()
|
||||||
app.install(EnableCors())
|
app.add_hook('after_request', apply_cors)
|
||||||
app.run(
|
app.run(
|
||||||
host=Settings.MONITOR_HTTP_BIND_ADDRESS,
|
host=Settings.MONITOR_HTTP_BIND_ADDRESS,
|
||||||
port=Settings.MONITOR_HTTP_PORT,
|
port=Settings.MONITOR_HTTP_PORT,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user