Initial structure
This commit is contained in:
parent
5ef2d67736
commit
61109d3665
|
@ -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)
|
|
@ -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
|
Loading…
Reference in New Issue