-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
43 lines (32 loc) · 1.18 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import logging
from spyne import Application, rpc, ServiceBase, Integer, Unicode
from spyne import Iterable
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
from wsgiref.simple_server import make_server
from src.database_manager import *
logging.basicConfig(level=logging.DEBUG)
create_database()
class HelloWorldService(ServiceBase):
@rpc(Unicode, Unicode, _returns=Iterable(Unicode))
def fazer_pedido(ctx, cliente, pedido):
yield insert_order(cliente, pedido)
@rpc(_returns=Iterable(Unicode))
def ver_pedidos(ctx):
lista: list = read_order()
count: int = 0
for i in lista:
count += 1
yield "Pedido {}: {}".format(count, i)
@rpc(Integer, Unicode, _returns=Iterable(Unicode))
def atualiza_pedido(ctx, index, status):
yield update_order(index, status)
application = Application([HelloWorldService],
tns='spyne.pedidos.crud',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11()
)
if __name__ == '__main__':
wsgi_app = WsgiApplication(application)
server = make_server('0.0.0.0', 8000, wsgi_app)
server.serve_forever()