From 61109d36653f12f274c2df1fd066ad0a04b9e646 Mon Sep 17 00:00:00 2001 From: el Mau Date: Tue, 17 Jan 2023 00:47:24 -0600 Subject: [PATCH] Initial structure --- source/main.py | 30 ++++++++++++++++++++++++++++++ source/main_debug.ini | 11 +++++++++++ 2 files changed, 41 insertions(+) create mode 100644 source/main.py create mode 100644 source/main_debug.ini diff --git a/source/main.py b/source/main.py new file mode 100644 index 0000000..e82de33 --- /dev/null +++ b/source/main.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +import falcon +import json + + +XML = """ + + + +""" + + +class JSONTranslator(): + def process_response(self, req, resp, resource, req_succeeded): + if not hasattr(resp.context, 'result'): + return + resp.body = json.dumps(resp.context.result) + + +class AppApi(object): + + def on_get(self, req, resp, rfc, cfdi): + resp.context['result'] = {'error': '', 'xml': XML} + resp.status = falcon.HTTP_200 + + +app = falcon.App(middleware=[JSONTranslator()]) +api = AppApi() +app.add_route('/api/{rfc}/{cfdi}', api) diff --git a/source/main_debug.ini b/source/main_debug.ini new file mode 100644 index 0000000..3074cba --- /dev/null +++ b/source/main_debug.ini @@ -0,0 +1,11 @@ +[uwsgi] +http = 127.0.0.1:8000 +wsgi-file = main.py +callable = app +master = true +processes = 2 +threads = 4 +py-autoreload = 1 +thunder-lock = true +#~ static-map = /static=../static +http-timeout = 300