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

17 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
  2. 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
  3. Thanks a lot for this great tutorial

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

    ReplyDelete
  5. Valuable tips we can find here.

    ReplyDelete
  6. 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
  7. This comment has been removed by the author.

    ReplyDelete
  8. 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
  9. 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
  10. I loved the information given above, I appreciate the writing. Are you a Class 12 student seeking expert guidance in Accountancy? Join Ziyyara’s online home tuition classes designed exclusively for 12th standard Accountancy.
    Book A Free Demo Today visit private tuition classes for class 12

    ReplyDelete
  11. Thank you so much for taking the time to share this wonderful article. Join Ziyyara's online English tuition classes for a personalized learning experience. Master the language, improve fluency, and boost your confidence in English communication with expert guidance and interactive sessions.
    For more info visit Tuition for english

    ReplyDelete

Popular Posts

Followers