CORS

In Fantastico framework, CORS (cross origin resource sharing) can be enabled easily per each individual controller method.

class fantastico.mvc.controller_decorators.CorsEnabled[source]

This class provides the cors behavior which ensures all cors required headers are appended to response. It is designed to be used on controller methods decorated with @Controller attribute.

@Controller(url="/api/filesystem/(?P<filename>.*)$", method="OPTIONS")
@CorsEnabled()
def upload_file_options(self, request, filename):        
    pass

As you can see there is no need to implement cors controller methods because the decorator does all the job.

In addition to CorsEnabled decorator, you can also configure the framework to globally append some headers to each response:

  1. Go to your settins profile (see fantastico.settings.BasicSettings)
  2. Change global_response_headers property and add all desired headers (e.g: Access-Control-Allow-Origin: “*”)