Re: 'Toolbox' object has no attribute 'CORS'
Kearney Taaffe <[email protected]>
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
@morecowbell
I installed cherrypy-cors on my system, and changed the server.py file to
look like this
import os
import cherrypy
*import cherrypy_cors*
from cherrypy.lib.static import serve_file
class Root(object):
pass
if __name__ == '__main__':
root = os.path.dirname(os.path.abspath(__file__)) # this file's
directory
* cherrypy_cors.install()*
cherrypy.config.update( {
'server.socket_host': '0.0.0.0',
'server.socket_port': 8010,
} )
conf = {
'/': {
'tools.staticdir.on': True,
'tools.staticdir.root' : root,
'tools.staticdir.dir': root + '/public/',
'tools.staticdir.index': root + '/public/app/views/index.html',
*'cors.expose.on': True*
}
}
cherrypy.quickstart(Root(), '/', conf)
This is working perfectly for me now! Thank you so much! I posted the
solution here so others who see this can know what I did to fix the
problem.
Thanks again!
On Wednesday, March 23, 2016 at 1:52:15 PM UTC-5, morecowbell wrote:
>
> assuming cherrypy-cors is installed, you're seemingly missing the module
> import and setup.
>
>
> On Tuesday, March 22, 2016 at 8:38:37 PM UTC-7, Kearney Taaffe wrote:
>>
>> I've created an AngularJS web app, being served by a CherryPy server.
>> It's calling an API which returns a JSON response
>>
>> The server.py (of my web application, not the API server) file looks like
>> this
>>
>> import os
>> import cherrypy
>>
>> from cherrypy.lib.static import serve_file
>>
>> class Root(object):
>> pass
>>
>> if __name__ == '__main__':
>> root = os.path.dirname(os.path.abspath(__file__)) # this file's
>> directory
>>
>> cherrypy.config.update( {
>> 'server.socket_host': '0.0.0.0',
>> 'server.socket_port': 8010,
>> } )
>>
>> conf = {
>> '/': {
>> 'tools.staticdir.on': True,
>> 'tools.staticdir.root' : root,
>> 'tools.staticdir.dir': root + '/public/',
>> 'tools.staticdir.index': root +
>> '/public/app/views/index.html',
>> 'tools.CORS.on': True
>> }
>> }
>>
>>
>>
>> cherrypy.quickstart(Root(), '/', conf)
>>
>>
>> However, when my angular app tries to hit the URI I get the following
>> error
>>
>> [22/Mar/2016:15:28:28] ENGINE Bus STARTING
>> CherryPy Checker:
>> The config entry 'tools.CORS.on' may be invalid, because the 'CORS' tool
>> was not found.
>> section: [/]
>>
>>
>>
>> AttributeError: 'Toolbox' object has no attribute 'CORS'
>>
>>
>> Any clue as to what I'm doing wrong?
>>
>
--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.