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

How to replace sublists within a list?
How to listen for an AUDIO file using Python and Selenium Webdriver
Storing Encrypted Data On A MySQL Database with Python, Pandas and SQLAlchemy [Connection Lost]
How to make python decorators work like a tag to make function calls “by tag”
Pandas - Remove index column
Setting SublimeRepl to work inside venv (sublime 3)
python-docx get info from dropdownlist (in table)
Creating audio file with gTTS for Google Speech API [duplicate]
Python: Make raw input remember commands [duplicate]
Can Omnicomplete in Vim for python/3 complete function names or just methods?
Slowness on iterating over namedtuple and dicts for defined pairs
I'm trying to put these inputs into a text file, [duplicate]
Printing Dictionaries? [closed]
OpenCV's frame count always printing 0
Including first and last elements in list comprehension
how to see output history on pycharm?

Categories

HOME
sharepoint
json
semantic-ui
puzzle
checkbox
angular2-routing
fparsec
computer-vision
search-engine
terrain
google-spreadsheet-api
eval
cockroachdb
wysiwyg
camera-calibration
cosmicmind
pdo
scaling
google-openid
anychart
primes
epicor
apple-tv
ghost-inspector
avplayeritem
spring-data-neo4j
chrome-native-messaging
system.data.sqlite
ivy
rowcount
helix-3d-toolkit
npm-shrinkwrap
pace
redhat-datavirt
codesys
topic-modeling
magiczoomplus
fax
code-composer
ical-dotnet
ssh.net
datalog
amazon-clouddrive
onmouseover
recycle-bin
jenkins-jira-trigger
webdatagrid
persistent
teiid
date-range
onresume
typhoon
manifest.mf
c#-interactive
picasa
glkit
aescryptoserviceprovider
mix
gameanalytics
angularjs-ng-pattern
gherkin
dbscan
squirrel
faraday
gradle-release-plugin
picking
spinlock
eml
brackets-shell
altbeacon
portfolio
windows-vista
site-prism
datasnap
paypal-nvp
mogrify
divide-by-zero
crash-dumps
httpie
sysfs
word-2013
belongs-to
cocoascript
proxies
korma
visualstatemanager
anjuta
openkinect
json-patch
dynamic-proxy
loop-invariant
nsmatrix
stagefright
symphony-cms
fortran77
magickwand
cbcentralmanager
ninject-extensions
responsetext
supersized
selectonemenu
querystringparameter
adsl
server-error
nagle
adobe-contribute
audiostreamer
email-spec
loadui
carbide
unreachable-code
delegatecommand
winverifytrust
graniteds
idictionary
filetime
system-codedom-compiler

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