mirror of
https://git.sr.ht/~cadence/NewLeaf
synced 2024-11-21 23:27:29 +00:00
Add Access-Control-Allow-Origin header
This commit is contained in:
parent
c506f65c71
commit
097b6bf584
17
index.py
17
index.py
@ -10,20 +10,17 @@ import json
|
|||||||
import traceback
|
import traceback
|
||||||
import requests
|
import requests
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
from cachetools import TTLCache
|
|
||||||
from extractors.video import extract_video
|
from extractors.video import extract_video
|
||||||
from extractors.channel import extract_channel, extract_channel_videos, extract_channel_latest
|
from extractors.channel import extract_channel, extract_channel_videos, extract_channel_latest
|
||||||
from extractors.manifest import extract_manifest
|
from extractors.manifest import extract_manifest
|
||||||
from extractors.search import extract_search
|
from extractors.search import extract_search
|
||||||
from extractors.suggestions import extract_search_suggestions
|
from extractors.suggestions import extract_search_suggestions
|
||||||
|
|
||||||
class Second(object):
|
@cherrypy.tools.register("before_finalize", priority=60)
|
||||||
def __init__(self):
|
def custom_headers():
|
||||||
self.video_cache = TTLCache(maxsize=50, ttl=300)
|
cherrypy.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
self.search_cache = TTLCache(maxsize=50, ttl=300)
|
|
||||||
self.search_suggestions_cache = TTLCache(maxsize=200, ttl=60)
|
|
||||||
self.channel_cache = TTLCache(maxsize=50, ttl=300)
|
|
||||||
|
|
||||||
|
class Second(object):
|
||||||
def _cp_dispatch(self, vpath):
|
def _cp_dispatch(self, vpath):
|
||||||
if vpath[:4] == ["api", "manifest", "dash", "id"]:
|
if vpath[:4] == ["api", "manifest", "dash", "id"]:
|
||||||
vpath[:4] = ["manifest"]
|
vpath[:4] = ["manifest"]
|
||||||
@ -110,4 +107,8 @@ class Second(object):
|
|||||||
return r # no idea if this is a good way to do it, but it definitely works! :D
|
return r # no idea if this is a good way to do it, but it definitely works! :D
|
||||||
|
|
||||||
cherrypy.config.update({"server.socket_port": 3000, "server.socket_host": "0.0.0.0"})
|
cherrypy.config.update({"server.socket_port": 3000, "server.socket_host": "0.0.0.0"})
|
||||||
cherrypy.quickstart(Second())
|
cherrypy.quickstart(Second(), "/", {
|
||||||
|
"/": {
|
||||||
|
"tools.custom_headers.on": True
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user