Search

28 March, 2018

How to import and use a font in your website ?



Most people like to use the default available list of fonts . But what if we liked some other font and we want to use it our own website .

There are free downloadable fonts on the web. When you download a zip of it , you generally would receive files of the format 'ttf', 'otf' etc. You can visit the site https://www.fontsquirrel.com and convert them into a format 'woff' .

16 March, 2018

How to use Docker with Python projects



Docker is the modern way to share ready made machines , so other can use it without the usual hassles of configuration and environment setup. I wanted to try it myself first hand, to see what the fuss is about.  I want to share what I found, so you start your project right now.

Before we start, for the absolute beginners who ABSOLUTELY NO IDEA about DOCKER, let me try to explain what it is:

It is a CONTAINER which CONTAINS ALL that you NEED to run your project. 

Dockers are the new generation Virtual Machines which totally remove the need to install another files on a system just to run or test something . They are just CONTAINERS with all the things necessary for our app to work. That's it .

08 March, 2018

Testing GET and POST calls using Flask


I was trying out Flask. In the process, I made a website that behaves like a server. It can help you test GET and POST calls.

It goes like this .

from flask import Flask, request
    app = Flask(__name__)
    
    @app.route('/method', methods=['GET', 'POST'])
    @app.route('/method/<wish>', methods=['GET', 'POST'])
    def method_used(wish=None):
        if request.method == 'GET':
            if wish:
                if wish in dir(request):
                    ans = None
                    s = "ans = str(request.%s)" % wish
                    exec s
                    return ans
                else:
                    return 'This wish is not available. The following are the available wishes: %s' % [method for method in dir(request) if '_' not in method]
            else:
                return 'This is just a GET method'
        else:
            return "You are using POST"


05 March, 2018

Why should we use Class in Python ?


Lots of people ask me, why should they use classes at all ? Well. I think its about control, and ease . It solves the headache of data sharing and accessibility. I am going to show you an example , which hopefully proves that classes and fundamentals like inheritance  are brilliant. Example: I have  two classes in the below program. Person and Manager . Manager has inherited the Person class (because he is a person too....almost (lol)) .