Skip to content

Commit

Permalink
Merge branch 'raoel-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
fboender committed Sep 7, 2020
2 parents 84e9084 + 8706e90 commit b7bfe27
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Basic web server / framework.
"""

from SocketServer import ThreadingMixIn
import BaseHTTPServer
import urlparse
import cgi
import urlparse
from SocketServer import ThreadingMixIn


class HTTPError(Exception):
Expand Down Expand Up @@ -57,6 +57,18 @@ def do_POST(self): # pylint: disable=invalid-name
environ={'REQUEST_METHOD': 'POST'})
self._call(self.path.strip('/'), params={'form_values': form_values})

def do_OPTIONS(self): # pylint: disable=invalid-name
"""
Handle OPTIONS request and return CORS headers.
"""
self.send_response(200, 'ok')
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS')
self.send_header('Access-Control-Allow-Headers', 'X-Requested-With')
self.send_header('Access-Control-Allow-Headers', 'Content-Type, '
'Authorization')
self.end_headers()

def _parse(self, reqinfo):
"""
Parse information from a request.
Expand Down

0 comments on commit b7bfe27

Please sign in to comment.