From dcdaad1b02386325797a5c72acf0aab01716a323 Mon Sep 17 00:00:00 2001 From: Admin Date: Fri, 7 Jun 2013 17:32:15 +0200 Subject: [PATCH] =?UTF-8?q?passage=20en=20soap=20:)=20Cette=20fois=20?= =?UTF-8?q?=C3=A7a=20marche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liaRest.py | 37 +++++++++++++++++++++++++++++++++++++ liaSoap.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 liaRest.py create mode 100644 liaSoap.py diff --git a/liaRest.py b/liaRest.py new file mode 100644 index 0000000..0bb4b52 --- /dev/null +++ b/liaRest.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +import subprocess +import os +import json +from lxml import etree +from flask import Flask, request, render_template +from processor.LiaTools import * +from processor.Orkis import Orkis +from flaskext.enterprise import Enterprise +from time import ctime +app = Flask(__name__) +enterprise = Enterprise(app) + +@app.route("/") +def docs(): + return render_template('index.html') + +@app.route("/tagger",methods=['POST']) +def cleaner(): + # Receive String from post parametre Raw text + dirtyString= request.values[u'string'] + # Charging Processor et check if they are okay ( aim is to dynamic charge later ) + orkisProc = Orkis(dirtyString) + # Processing + # Adding lemm of each words cause we went ther phonem too + taggedTable= orkisProc.getDico() + # Returning a row text to be parse client side + return unicode(taggedTable) + +class OrkisService(enterprise.SOAPService): + @enterprise.soap(returns=enterprise._sp.String) + def get_phon(self): + return ctime() + +if __name__ == '__main__': + app.debug = True + app.run(host='0.0.0.0') diff --git a/liaSoap.py b/liaSoap.py new file mode 100644 index 0000000..942c785 --- /dev/null +++ b/liaSoap.py @@ -0,0 +1,32 @@ +from spyne.application import Application +from spyne.decorator import srpc +from spyne.service import ServiceBase +from spyne.model.primitive import Integer +from spyne.model.primitive import Unicode +from spyne.model.complex import Iterable +from spyne.protocol.soap import Soap11 +from spyne.server.wsgi import WsgiApplication +from processor.Orkis import Orkis + +class HelloWorldService(ServiceBase): + @srpc(Unicode, _returns=Unicode) + def say_hello(name): + orkis=Orkis(name) + orkis.getDico() + return str(orkis) + +application = Application([HelloWorldService], + tns='spyne.examples.hello', + in_protocol=Soap11(), + out_protocol=Soap11() +) + +if __name__ == '__main__': + # You can use any Wsgi server. Here, we chose + # Python's built-in wsgi server but you're not + # supposed to use it in production. + from wsgiref.simple_server import make_server + + wsgi_app = WsgiApplication(application) + server = make_server('0.0.0.0', 8000, wsgi_app) + server.serve_forever() -- 1.8.2.3