Articles with tag - python

Install Python 3.7 on CentOS 7

Posted on 1 year ago by Ping Cheng

CentOS series natively comes with Python 2 installed, since there are some system level parts are depending on python 2, it is not safe and easily to replace python 2 with python 3.

Therefore, this article would express install python with altinstall.

Step 1 Install dependency

yum install gcc openssl-devel bzip2-devel libffi-devel wget

Step 2 Download Python 3 source code

cd ~
tar xzf Python-3.7.2.tgz

Step 3 Install

cd Python-3.7.2.tgz
./configure --enable-optimizations
make altinstall

Note, if you encountered some error message such as no permission, please use sudo.


python3.7 -V
Python 3.7.2

python -V
Python 2.7.5

Health checking on your websites

Posted on 1 year ago by Ping Cheng

If you are running one or a few your websites, you definitely would like to avoid any access issue to your site. However, you cannot stop it happens. When your website does have some access issues, you need to know at the first place before any of your visitors, and then you can have some time to fix it.

A straightforward way to monitor your website is writing a small script that can send a request to your site and check if the response is what we are expected. If you cannot hear a response or the response is something you are not acceptable, then an issue can be identified and send a notification to your preferred channel.

This is a very simple python script that we can use

import urllib
import json
import urllib2
import time

def notify_slack(options):
    wekbhook_url = 'my-slack-webhook-url'
    data = json.dumps(options)
    request = urllib2.Request(wekbhook_url, data)

def check_url(url, expected_status = 200):


[ Read More ]

Hand crafted with by Ping Cheng