|
@@ -14,14 +14,15 @@ from datetime import timedelta
|
|
import View.view_error_management as view_error_management
|
|
import View.view_error_management as view_error_management
|
|
from flask_limiter import Limiter
|
|
from flask_limiter import Limiter
|
|
from flask_limiter.util import get_remote_address
|
|
from flask_limiter.util import get_remote_address
|
|
-logger = logging.getLogger(logger_name + ".VIEW")
|
|
|
|
-
|
|
|
|
|
|
+from flask_cors import CORS
|
|
|
|
|
|
|
|
+logger = logging.getLogger(logger_name + ".VIEW")
|
|
|
|
|
|
__app__ = Flask("OpenIsp")
|
|
__app__ = Flask("OpenIsp")
|
|
__app__.secret_key = "aseqzdwxc"
|
|
__app__.secret_key = "aseqzdwxc"
|
|
__app__.permanent_session_lifetime = timedelta(minutes=2)
|
|
__app__.permanent_session_lifetime = timedelta(minutes=2)
|
|
-
|
|
|
|
|
|
+__app__.logger = logger
|
|
|
|
+#CORS(__app__)
|
|
|
|
|
|
__resource_array__ : array
|
|
__resource_array__ : array
|
|
__id_counter__ : int = 1
|
|
__id_counter__ : int = 1
|
|
@@ -88,10 +89,6 @@ def init() :
|
|
privileges.init()
|
|
privileges.init()
|
|
|
|
|
|
view_error_management.define_error_management(__app__)
|
|
view_error_management.define_error_management(__app__)
|
|
- from flask.logging import default_handler
|
|
|
|
- __app__.logger.removeHandler(default_handler)
|
|
|
|
- for hand in logger.handlers :
|
|
|
|
- __app__.logger.addHandler(hand)
|
|
|
|
|
|
|
|
@__app__.route('/api/login',methods = ['POST'])
|
|
@__app__.route('/api/login',methods = ['POST'])
|
|
def login():
|
|
def login():
|
|
@@ -141,6 +138,14 @@ def routes():
|
|
return jsonify(routes)
|
|
return jsonify(routes)
|
|
|
|
|
|
|
|
|
|
|
|
+@__app__.after_request
|
|
|
|
+def after_request(response):
|
|
|
|
+ header = response.headers
|
|
|
|
+ header['Access-Control-Allow-Origin'] = '*'
|
|
|
|
+ header['Access-Control-Allow-Methods'] = 'GET,HEAD,OPTIONS,POST,PUT'
|
|
|
|
+ header['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
|
|
|
|
+ return response
|
|
|
|
+
|
|
|
|
|
|
def run() :
|
|
def run() :
|
|
global __server_process__
|
|
global __server_process__
|