main.py 1.01 KB
from Libmod.armador import NegroReport
from flask import Flask, send_file
from flask import request
from flask_restful import Resource, Api
from flask import jsonify
import json
import datetime

app = Flask(__name__)
api = Api(app)

class indice(Resource):
    def get(self):
        datetime_object = datetime.datetime.now()
        print(datetime_object)
        hora = str(datetime_object)
        return({"hora":hora})

    def post(self):
        content = json.loads(request.data)
        #print(content)
        retorno = self.acciones(content)
        return(retorno)

    def acciones(self, content):
        rep = NegroReport()
        rep.ConfiguradorDB(content["DBconf"])
        rep.Encabezado(content)
        rep.DB.SELECT = content["select"]
        return(rep.Generador())



class icono(Resource):
    def get(self):
        return send_file("imagen/icon.ico")


api.add_resource(indice, "/")
api.add_resource(icono, "/favicon.ico")
if __name__ == '__main__':
    app.run(debug=False, port=11876, host="0.0.0.0")