Merge pull request #60 from bertoncelj1/cors

Add a header for CORS support
This commit is contained in:
Alex Yatskov 2017-12-30 13:08:36 -08:00 committed by GitHub
commit cee92290ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 478 additions and 277 deletions

View File

@ -217,7 +217,8 @@ class AjaxServer:
def resetHeaders(self): def resetHeaders(self):
self.headers = [ self.headers = [
['HTTP/1.1 200 OK', None], ['HTTP/1.1 200 OK', None],
['Content-Type', 'text/json'] ['Content-Type', 'text/json'],
['Access-Control-Allow-Origin', '*']
] ]
self.extraHeaders = {} self.extraHeaders = {}
@ -268,7 +269,7 @@ class AjaxServer:
params = json.loads(makeStr(req.body)) params = json.loads(makeStr(req.body))
body = makeBytes(json.dumps(self.handler(params))) body = makeBytes(json.dumps(self.handler(params)))
except ValueError: except ValueError:
body = json.dumps(None); body = makeBytes(json.dumps(None))
resp = bytes() resp = bytes()
@ -785,7 +786,8 @@ class AnkiBridge:
'answer': card._getQA()['a'], 'answer': card._getQA()['a'],
'buttons': [b[0] for b in reviewer._answerButtonList()], 'buttons': [b[0] for b in reviewer._answerButtonList()],
'modelName': model['name'], 'modelName': model['name'],
'deckName': self.deckNameFromId(card.did) 'deckName': self.deckNameFromId(card.did),
'css': model['css']
} }

747
README.md

File diff suppressed because it is too large Load Diff