Initial structure

This commit is contained in:
el Mau 2023-01-17 00:47:24 -06:00
parent 5ef2d67736
commit 61109d3665
2 changed files with 41 additions and 0 deletions

30
source/main.py Normal file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env python
import falcon
import json
XML = """<?xml version="1.0" encoding="utf-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4">
<cfdi:Emisor Rfc="SPE11071516A"/>
</cfdi:Comprobante>
"""
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)

11
source/main_debug.ini Normal file
View File

@ -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