dagarcos 3 miesięcy temu
commit
26b091436f

+ 0 - 0
__init__.py


+ 33 - 0
app.py

@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+Created on Sun Jul 14 11:50:51 2019
+
+@author: dagarcos
+"""
+
+import os
+from flask import Flask, flash, render_template, redirect, request, url_for
+from flask_cors import CORS, cross_origin
+from models.db import db
+from controllers.mainController import mainController
+
+app = Flask(__name__)
+app.secret_key = os.urandom(12)
+app.config['SQLALCHEMY_DATABASE_URI'] = ""
+app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
+db.init_app(app)
+
+app.register_blueprint(mainController)
+CORS(app, origins = "*", allow_headers=["Content-Type", "content-type", "Authorization", "Access-Control-Allow-Credentials", "Access-Control-Allow-Headers", "Access-Control-Allow-Origin"], supports_credentials=True)
+
+if __name__ == '__main__':
+	app.run(host='0.0.0.0', debug=True)
+
+@app.after_request
+def after_request(response):
+    response.headers.add('Access-Control-Allow-Origin', '*')
+    response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
+    response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS')
+    
+    return response

+ 10 - 0
app.wsgi

@@ -0,0 +1,10 @@
+import os
+import sys
+import logging
+
+logging.basicConfig(stream=sys.stderr)
+
+sys.path.insert(0, "/var/www/falla22")
+sys.path.insert(1, '/var/www')
+
+from app import app as application

+ 0 - 0
controllers/__init__.py


BIN
controllers/__pycache__/__init__.cpython-35.pyc


BIN
controllers/__pycache__/__init__.cpython-39.pyc


BIN
controllers/__pycache__/mainController.cpython-35.pyc


BIN
controllers/__pycache__/mainController.cpython-37.pyc


BIN
controllers/__pycache__/mainController.cpython-39.pyc


+ 23 - 0
controllers/mainController.py

@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+@author: dagarcos
+"""
+import os
+from flask import render_template, Blueprint, url_for, redirect, request, jsonify
+from flask_cors import CORS, cross_origin
+from services.testService import TestService
+
+mainController = Blueprint('mainController', __name__)
+CORS(mainController, origins = '*', allow_headers=['Content-Type', 'content-type', 'Authorization', 'Access-Control-Allow-Credentials', 'Access-Control-Allow-Headers'], supports_credentials=True)
+
+tserv = TestService()
+
+@mainController.route('/test', methods=['GET'])
+def getDatos():
+    return jsonify(tserv.get_all())
+
+@mainController.route('/status', methods=['GET'])
+def getStatus():
+    return "OK"
+

BIN
models/__pycache__/barrio.cpython-39.pyc


BIN
models/__pycache__/db.cpython-39.pyc


+ 12 - 0
models/db.py

@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+Created on Sun Jul 14 11:50:51 2019
+
+@author: dagarcos
+"""
+
+
+from flask_sqlalchemy import SQLAlchemy
+
+db = SQLAlchemy()

BIN
services/__pycache__/barrioService.cpython-39.pyc


+ 14 - 0
services/testService.py

@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+Created on Sun Jul 14 11:50:51 2019
+
+@author: dagarcos
+"""
+
+from models.db import db
+
+class TestService:
+
+    def get_all(self):
+        return {'1':'a', '2':'b', '3':'c'}