cherrypy-cors's People
cherrypy-cors's Issues
CORS and routes dispatcher
Hi,
I would like to integrate your pakage in my application.
I have a RoutesDispatcher more or less like this example.
Could you help me?
Thanks
Decorator not working
In investigating #1, I tried using the decorator, as described in the docstrings, but when I did, it didn't work. I'm not sure if it was user error or a bug in the decorator, so more investigation is needed.
Runable example
Originally reported by: Markus Bergholz (Bitbucket: markuman, GitHub: markuman)
A minimal runable example file would be very helpful. When searching for cherrypy_cors.install()
on github, you get >10 different variations how people try using cherrypy_cors.
Currently I'm trying to receive a json object with @cherrypy.tools.json_in()
from a HTML file whitch isn't served by cherrypy
#!html
<html>
<head>
<script>
function makeRequest()
{
var xmlhttp = new XMLHttpRequest(); // new HttpRequest instance
xmlhttp.open("POST", "http://localhost:8080");
xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xmlhttp.send(JSON.stringify({user:"John Rambo", time:"2pm"}));
}
</script>
</head>
<body>
<form name="frm1" id="yourTextBox" onsubmit="makeRequest()">
<input type="submit" value="Submit">
</form>
</body>
</html>
I hope you can help me.
Headers not applied when Origin includes Scheme
According to the spec and the wikipedia simple example, the Origin header is a URI. If the URI has a scheme, cherrypy-cors doesn't match it.
Support origin whitelisting
Feature Request
Add support to expose()
and preflight()
for enabling CORS for specific domains.
Sample Usage
Decorator
DOMAIN_REGEX = re.compile('^sd[1-9]\.example\.org$')
ORIGINS = ['a.example.com', 'b.example.net', DOMAIN_REGEX]
class MyResource(object):
@cherrypy_cors.tools.preflight(
allowed_methods=['GET', 'DELETE', 'PUT'], origins=ORIGINS)
def OPTIONS(self):
self._delete()
@cherrypy_cors.tools.expose(origins=ORIGINS)
def DELETE(self):
self._delete()
Configuration
config = {
'/resources': {
'cors.expose.on': True,
'cors.expose.origins': ['my.example.com', 'www.example.net'],
'cors.preflight.origins': ['my.example.com', 'www.example.net'],
}
}
Preferably, expose()
and preflight()
could read the origins parameter from a common config setting (I don't know whether cherrypy tools support that).
config = {
'/resources': {
'cors.expose.on': True,
'cors.origins': ['my.example.com', 'www.example.net'],
}
}
Delete this repo
The project has been migrated to cherrypy/cherrypy-cors.
Publish docs to RTD
Without this, they aren't googlable.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.