Tuesday, August 26, 2014

Why Jython when you can microservice with Flask

Over the last little while I have been working on Sibbly it's my little pet project to try summarize, group, filter and target software development information on the web. All 'n all a rather ambitious task, but the worst thing that could happen is that I learn something, so there is really no risk. It is still currently in a very closed beta, only occasionally showing it to fellow work colleagues and getting some input.

After initially starting development for Sibbly on Ubuntu, as I was always planning on deploying on Ubuntu, I had migrated back to windows, and after a couple weeks of work when finally deploying to Ubuntu... Surprise! it obviously did work right off the bat.

The issue I ended up with was, there seems to be a classpath issue between Spring Boot, it's embedded Tomcat instance and Jython. The reason I use Jython is for an awesome library called Pygments.

So after much dismay and checking all the Java alternatives and attempted Pygment ports (jygments, jgments), I started thinking of alternate solutions.
Having recently read: Microservices I decided to look at a way of interacting with Python more indirectly.
This lead me to: Flask
Within a couple minutes thanks to: Awesome Flask Example
I had the following up and running:


What this little bit of Python does is wrap and expose the highlight and guess functionality from Pygments via a RESTful service accepting and producing JSON.

I deploy Sibbly on DigitalOcean
To install Python on my droplet, I followed the process below:

sudo apt-get install python-dev build-essential  
sudo apt-get install zlib1g-dev
sudo apt-get install libssl-dev openssl
sudo apt-get install python-pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper

export WORKON_HOME="$HOME/.virtualenvs"
source /usr/local/bin/virtualenvwrapper.sh

sudo mkdir /opt/python3.4.1
wget http://python.org/ftp/python/3.4.1/Python-3.4.1.tgz
tar xvfz Python-3.4.1.tgz
cd Python-3.4.1
./configure --prefix=/opt/python3.4.1
make  
sudo make install

mkvirtualenv --python /opt/python3.4.1/bin/python3 py-3.4.1

workon py-3.4.1

pip install flask
pip install pygments

Once that was done to run the Flask app:
python app.py & disown

18 comments:

  1. Flask is awesome. I have used it for web scraping work. I have made custom scraper with it. Here is link to it. http://webdata-scraping.com/web-scraping-application-custom-scraper-development-project-demo/

    ReplyDelete
    Replies
    1. IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.

      IEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.

      corporate training in chennai corporate training in chennai

      corporate training companies in india corporate training companies in india

      corporate training companies in chennai corporate training companies in chennai

      I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai Project Centers in Chennai

      Delete
  2. The Borderlands series is one of the best in the lot of action gaming. Now the third installment of the series is about to release with the addition of two new varieties of items including the laser gun and I am waiting for this game to release to check it out myself. Hope it lives up to our expectations.You can check out Borderlands 3 Price

    ReplyDelete
  3. We are a site providing you information about the latest smartphone applications and also the download and install process of the same.
    We are certain that you would have a great experience of using the apps on your smart devices Follow the link

    ReplyDelete
  4. Thanks a lot for this great tutorial

    ReplyDelete
  5. Good information should be provided to more people.

    ReplyDelete
  6. Valuable tips we can find here.

    ReplyDelete
  7. I have in some way or other worked with, tried, read about, implemented, studied, interested in or affected by the following in the last year.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Flask is the best and powerful web framework to write python code. Moreover, with our Mobile Laser Tag Game in San Diego CA, bring your party to life by adding adventure and challenge.

    ReplyDelete
  10. There are so many useful information about Why Jython when you can microservice with Flask in your post, I like it all the time. And I want to share this assignment writing service in brighton with you, you can take a look. This is very useful.

    ReplyDelete

Popular Posts

Followers