August 12, 2014

Future of Web Development : AnuglarJs + REST API ?

It's a paradigm shift in web development. Unlike the days we used to develop web apps using classic Asp, Asp.Net or Php, the focus has changed into decoupling the frontend and backend. More and more web apps are adapting this methodology mainly due the evolution of mobile usage.

With mobile & tablets revolution, developers are constantly finding ways to develop a single app to support all of the different devices and their browser sizes. It has been always difficult and costly to develop native apps for various different mobile platforms. Although the responsive design was the solution, it is extremely hard to avoid unnecessary page reloads while using the web app on mobile devices.

SPA - Single Page App concept was the solution to the problem. However until the release of AngularJs, it wasn't very enjoyable development for the developers. There were plethora of MVC JavaScript libraries but none of them was even nearly good as AngularJs. While the AnugularJs solves the frontend problem, the backend lies in RESTful API's. The main advantage in this architecture is the app is decoupled hence frontend and backend can be developed using different technologies. For example, while the frontend is AngularJs, the backend API can be developed in Node.js, Asp.Net Web API or any other API provider technology.

The basics of AngularJs + API driven Web app.


This should be the preferred approach for any new web application development. However for the apps which are monolith or legacy could still gain the benefits by modularizing the APIs as shown in the following example.  For example, some parts of the apps can be decoupled using an API layer on top of the legacy/monolith web application.


One of the best approaches to write a scalable backend API is by using micro-services architecture, which will be discussed in my next post.

Writing scalable & high performance web applications have been a challenge, by making it device agnostic is even challenging. It is evident that AngujarJs + APIs solve the challenging nature of web apps to support multiple devices and increase the performance. 



February 11, 2014

Sending Emails using Templates

Here is a simple Python module to send emails using HTML/TEXT templates. Feel free to use the code.

https://github.com/ludmal/pylib

Step 1:

Create a TEXT/HTML file with the Keys as below
Hi [username],

Thank you for your registration.

Best regards,
[from]
[url]

Step 2:

Create a template passing the values to replace with the keys in template
values = {}
values['username'] = 'Ludmal de silva!'
values['from'] = 'The Team'
values['url'] = 'http://www.ludmal.com'
temp = EmailTemplate(template_name='welcome.txt', values=values)

Step 3:

Create a Mail Server
server = MailServer(server_name='smtp.gmail.com', username='', password='', port=0,   require_starttls=True)

Step 4:

Create a mail message and send the email
msg = MailMessage(from_email='ludmal@gmail.com', to_emails=['ludmal@gmail.com'], subject='Welcome')
send(mail_msg=msg, mail_server=server, template=temp)
Follow me on Twitter @ludmal

February 7, 2014

Python File Archiver

I always wanted to quickly cleanup my harddrive without manually searching files and moving them. So here is the solution, a simple File Arhicver python script which I wrote to clean up my hard drive. It will search for files older than a given time period & size (parameterized) and then move to a Arhicve folder. I'll try to improve the code when I get some free time and here is the script file, download and feel free to use it.

https://github.com/ludmal/pylib/blob/master/file_archiver