What is the simplest way to offer/consume web services in jython? - python

I have an application for Tomcat which needs to offer/consume web services. Since Java web services are a nightmare (xml, code generation, etc.) compared with what is possible in Python, I would like to learn from your experience using jython instead of java for offerring/consuming web services.
What I have done so far involves adapting http://pywebsvcs.sourceforge.net/ to Jython. I still get errors (namespaces, types and so), although some of it is succesful for the simplest services.

I've put together more details on how to use webservices in jython using axis. Read about it here: How To Script Webservices with Jython and Axis.

PyServlet helps you configure Tomcat to serve up Jython scripts from a URL. You could use this is a "REST-like" way to do some basic web services without much effort. (It is also described here.)
We used a similar home grown framework to provide a variety of data services in a large multiple web application very successfully.

Related

Python (back-end) and Kotlin (front-end) for Android

Ok I was doing some data science in python over the weekend and I got to looking at python for mobile development. I was curious as to if it's possible to use both Python (back-end) and use Kotlin (front-end) together?
I know python is a non GUI unless you use kivy or flask. However I was thinking if it's possible can you cross python and Kotlin together.
There is a lot apps that use python as the backend, and another language for the front end. I have done some research and found that Kivy (unstable from my research) can be used for mobile development. However for Android Kotlin is the preferred choice by Google.
Which throws me off because Google uses python for the backend. So when you look at the Google Apps on the Play Store, are they using python and java in mobile apps?
The app I am planning which will be released to Google Play on my developer page will be a Data Driven app. So things would go much smoother if I could combine the two.
Has anyone tried using python and Kotlin? However, would I be stuck with Python and Kivy?
The language used to program frontend vs backend don't matter, the only thing that matters is how the two communicate (assuming when you say backend you mean like a server and not like a game engine). Traditionally, applications will communicate with a backend using a REST API. So long as both sides abide by the same rules for talking to each other, it doesn't matter what language they were programmed in, known as a communication protocol.
The situation that you presented of a Kotlin frontend with a Python backend is definitely being used in production environments, and you shouldn't be afraid to do so either.
See also this related question, though I personally wouldn't recommend using Python to write an Android application because I believe natively supported first-class languages are going to produce more performant, reliable apps than non-native second/third-class languages (I haven't done more than find that SO question, so take my opinion with a grain of salt)

Python or Node.js for a Web app which interfaces with a USB devices?

I'm looking to develop a web app that controls Concept2 rowing gym equipment connected to the users computer via USB. I'm trying to decide what approach I should take in developing something like this.
Control of these devices has been achieved in the past both in python:
(https://github.com/uvd/PyRow)
and using node/jQuery:
(https://github.com/tijmenvangulik/ErgometerJS).
An SDK and documentation is provided by the developers of Concept2 gym equipment. DLL and CSafe commands are used to interface with the machines monitors.
(https://www.concept2.com/service/software/software-development-kit)
I'm looking for recommendations on how I should this tackle this project. At the moment python seems like the best approach however I have no idea how I can run these python files through a website interacting with the java script front end.
Any advice or pointers is appreciated.
David
You task looks like a simple SCADA solution with web interface.
You choice depends on whether you have experienced developers, who are able to use modern frameworks like Vue.js, Angular, React and others or not.
Really, in your particular case - monitoring equipment over web, you don't necessary need to invest a lot in your front-end - depends on your target audience. Is it a single service engineer? If yes, probably your front-end should be minimalistic, you can use Python with Twisted for static web server and build your frontend on bootstrap plus jquery. This is a fast win solution and you can implement it even if you've never worked with web.
More complex approach, requiring more engineering, is Python + Flask.
If you feel ready for modern frameworks, like Vue, React, Angular, then, possibly, you'd better look at NodeJs as a backend. They are better integrated with NodeJs and its package manager npm. You will need it to build the project on your server side; also some people treat it as a solid solution, when using the same language (javascript) for both backend and frontend. As for me, it doesn't really matter a lot.

Extensible Local HTTP Server with Framework in Python

I'm trying to build a desktop application using Python. To make it able to be used on as many platforms as possible, I think web UI may be a good choice. This boils down to the problem of making a local HTTP server first. I did some survey and found that people are mainly talking about BaseHTTPServer and SimpleHTTPServer. For prototyping, subclassing them may suffice.
Besides pure prototyping, I also want to leave some room for extension to real service. That is, once mature, I'd like to move the codes to a real dedicated HTTP server, so that end users only need a browser to use it.
I say "extensible" in the following sense:
The code modification is as minimum as possible in the migration process.
I will focus on algorithm in the prototyping stage. I also want to leave some room for future front end designer.
It looks WSGI + Django is a widely mentioned combination. After some search, what I found is using WSGI in apache or nginx. Is it possible to use self-contained modules? i.e. wsgiref + Django, so that I can start everything just from one entry script. I don't want to bother potential first adopters by asking them install apache and configure it. It will be very good if you have sample codes or pointers for further reading.
I'm new to Python and web programming in Python. Thanks for your help. I just try to make sure I'm on the right track. My underlying algorithms is implemented in Python 2.7. So the UI solution had better also be in Python 2.7.
I think what you may want is Bottle. It is a web framework that only needs the standard library to be installed. It also has compatibility with many other production servers, as well as shipping with it's own development server. And if that isn't good enough, it is all in a single file, and has support with many different templating languages, as well as it's own built in templating language.
Check it out here: http://bottlepy.org/docs/dev/
As mentioned bottle is a good choice, I personally like Flask, which if I recall correctly is what bottle is based off of. Anyways there are three things that really make Flask a joy to use.
Blueprints - essentially an application architecture
Flask-Sijax - allows for comet technology
Celery - an asynchronous task queue/job queue based on distributed message passing
there are a lot of other plugins, including one for an admin interface that I haven't tried out yet but it looks promising, and it works with Python 2.7

Python RESTfull Server

I am new in python and I have to run a project about web services with the following specs:
Windows Server (2003/2008)
REST architecture enabled
Python platform (any version)
My questions are:
Which web server fits better (IIS, Apache, ...)?
May I use GoogleAppEngine for commercial purposes?
In order to make RESTful web services on windows which python modules I will have to have?
Does anyone have a better architecture in his mind about these specs?
Thank you in advance,
Which web server fits better (IIS, Apache, ...)?
Fits what better? Fits Windows? Fits RESTful web services?
It doesn't much matter. Which ever one you can configure and manage.
In order to make RESTful web services on windows which python modules I will have to have?
All of them.
REST is simply a small extension to HTTP. Any web server and web framework can do it.
Many of us use Django and Piston. Some use Werkzeug.
Google "Django REST" or "Python REST" and you'll find a real lot of great alternatives.
Does anyone have a better architecture in his mind about these specs?
Since this is so vague, it's not possible to have a "better" architecture. Details would be required so suggest any improvements.
uWSGI on nginx.
Yes, just enable billing and set a budget.
A lot of people like CherryPy for RESTful services.
Not unless you provide a list of requirements, there is way too many options.

Amazon AWS web framework for Python

I dealt with GAE before and I like simplicity of its webapp. Now I am trying to learn how to work with Amazon EC2. My question - where do I start to make a simple web application that I will be able to access form browser? I suppose I should use WSGI for this purpose. I don't want to use Django as I want to keep the application small and lightweight without unnecessary features. What can you recommend? Thanks.
AWS and GAE are very different. GAE very strictly defines what you can and can't do in terms of development environment. AWS gives you a server to do whatever you want with.
GAE is good when you don't want to have to figure out how all the pieces fit together to scale well. AWS is good when you need flexibility to do whatever you want in your environment.
So to answer your question -- you can use any framework / environment you like.
Personally, I like Django/Pinax for anything requiring a user system. You want a lighter weight system, I've heard good things about Pylons.
Here's a listing of a few others:
http://wiki.python.org/moin/WebFrameworks
Since we're talking AWS, it doesn't have to be python. Ruby on Rails is great.
As already mentioned, you have a lot more flexibility with Amazon than with GAE. If you want to stick with Python and would like to be able to access your app through your browser, you might consider web2py, which enables you to edit and manage your apps through a web-based IDE and admin interface (see demo).
web2py was designed for ease of use and developer productivity, so it's very easy to learn and get going quickly, and you can get a lot done with very little code. Although it's easy to do simple (and even not-so-simple) things quickly and easily, if your app gets more complex, web2py can handle that too, as it is a well-integrated full-stack framework with lots of built-in functionality, including a database abstraction layer, form handling and validation, access control, web services, and easy Ajax integration.
web2py runs on GAE out of the box, and web2py apps are portable from GAE to other platforms without requiring any code changes. However, if you're looking for a simple, scalable cloud hosting option with more flexibility than GAE, you might take a look at the new DotCloud (still in beta), which actually runs on EC2. There's a demo web2py app running there now, and a tutorial explaining the simple deployment process.
If you have any questions about web2py, you'll get lots of help from the friendly and responsive mailing list. I know some of the users have hosted web2py apps on EC2. For example, this demo Q&A site powered by web2py is hosted on EC2.

Categories

Resources