CORS + fake login
This commit is contained in:
parent
1ea4ec5df6
commit
49dce8ecaa
1 changed files with 19 additions and 4 deletions
23
server.py
23
server.py
|
@ -1,10 +1,10 @@
|
|||
from bottle import route, run,template,app,default_app
|
||||
from bottle import route, run,template,app,default_app,request,response,get,post
|
||||
import logging
|
||||
import json
|
||||
import os
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG,)
|
||||
log=logging.getLogger("rudemaps")
|
||||
log=logging.getLogger("rudemaps: "+__name__)
|
||||
CONFIG={}
|
||||
|
||||
|
||||
|
@ -27,14 +27,29 @@ def root():
|
|||
def myName(item):
|
||||
return template('map_template', item=item)
|
||||
|
||||
load_config()
|
||||
@get('/login')
|
||||
@post('/login')
|
||||
def login():
|
||||
#response.status_="403 Login failed"
|
||||
response.headers['Access-Control-Allow-Origin'] = '*'
|
||||
print request.body
|
||||
return {"status":"KO","error":"login failed"}
|
||||
|
||||
@route('/<:re:.*>', method='OPTIONS')
|
||||
def enableCORSGenericRoute():
|
||||
print 'Generic regex route'
|
||||
response.headers['Access-Control-Allow-Origin'] = '*'
|
||||
response.headers['Access-Control-Allow-Methods'] = "POST, GET, OPTIONS"
|
||||
response.headers['Access-Control-Allow-Headers'] = "content-type"
|
||||
|
||||
if __name__=='__main__':
|
||||
#DEVEL SERVER
|
||||
from bottle import debug
|
||||
debug(True)
|
||||
run(host='localhost', port=9093,reloader=True)
|
||||
load_config()
|
||||
run(host='localhost', port=8080,reloader=True)
|
||||
else:
|
||||
#WSGI
|
||||
load_config()
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
application = default_app()
|
||||
|
|
Loading…
Reference in a new issue