python


Mod_wsgi and Apache. Where is Access-Control-Allow-Origin needed?


I'm sending data via JS to my apache2 server running mod_wsgi via:
$.ajax({
method: "POST",
url: "https://annotatie01.io.tudelft.nl/app",
data: "test-data",
success: function(response) {
console.log(response)
}
});
If the .wsgi file i'm sending to is as follows, it works:
def application(environ, start_response):
status = '200 OK'
length = int(environ.get('CONTENT_LENGTH', '0'))
data = environ['wsgi.input'].read(length)
response_headers = [('Content-type', '*'),
('Content-Length', str(len(data)))]
start_response(status, response_headers)
return data
When I try to save using something like f = open(), or when I try to access a SQL database:
import sqlite3
def application(environ, start_response):
status = '200 OK'
length = int(environ.get('CONTENT_LENGTH', '0'))
data = environ['wsgi.input'].read(length)
conn = sqlite3.connect('/var/database/material3.db')
c = conn.cursor()
c.execute('SELECT image from image_table limit 1')
data = c.fetchall()
response_headers = [('Content-type', '*'),
('Content-Length', str(len(data)))]
start_response(status, response_headers)
return data
I get an XMLHttpRequest Error > No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
I tried added Header set Access-Control-Allow-Origin "*" to the httpd.conf, as well as to the main Apache configuration, but that did not work. I've always tried adding ('Access-Control-Allow-Origin','*') to the response_headers.
How(and where) do I enable access-control-allow-origin, so that I can access the sqlite database, or write something using f = open().

Related Links

Get_all_values from Google Spreadsheet
Accelerating matplotlib figure update
Python not finding installed packages through pip on Linux
How to append 3D numpy array to file?
Selective comparison of class objects
Global event handlers in wxPython (Pheonix)
What does the Mayavi contour3d docs mean when it refers to “the arrows”?
Which python module is handy for simple 2-dimension graphic demonstration task?
Why does numpy.polyfit return non-zero values for straight line data?
AttributeError: 'FeatureChartParser' object has no attribute 'nbest_parse'
How to get type of the file from the Google Cloud Storage based on its blobkey?
Custom collections in SQL Alchemy
SqlAlchemy + MySql 1205, 'Lock wait timeout exceeded; try restarting transaction'
Getting the float numbers from this string (Python)
Django function calls
How do I limit the amount of values in a list - Python 3

Categories

HOME
laravel-5
crystal-reports
batch-processing
xamarin.android
cocos2d-x-3.0
apache2
yocto
bro
httpclient
dropbox
informatica-powercenter
qt-installer
squarespace
redux-observable
google-people
raphael
sensu
countif
multiplayer
iup
rworldmap
jquery-scrollify
tflearn
cronet
iis-10
dss
edge-detection
hana-studio
pcre
websauna
shapes
viewstate
ksoap
swagger-editor
ical-dotnet
xbim
g1gc
powermta
rkt
aqgridview
shutdown
bnd
cgcontext
text-classification
tcserver
svn-merge
payu
tomcat5
django-filer
inotifypropertychanged
search-regex
approval-tests
asymptote
cctray
document-oriented-db
mysqldumpslow
selendroid
p-np
sem
virus
django-1.6
kallithea
cpu-speed
cloudpebble
node-imagemagick
argument-passing
magic-numbers
dbsetup
help-viewer
opensocial
dynamic-proxy
angulartics
nimrod
nscolor
mailcore
template-haskell
nintendo
electronic-signature
msbuildextensionpack
adobe-contribute
gwt-2.2-celltable
linfu
graph-layout
odbc-sql-server-driver
writing

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App