Install and Running Supervisord in virtualenv python 2.7

The thing is your default python is 3.x and supervisord is not stable/ready yet for python 3.x so i suggest a solution is to run supervisord in virtualenv of python 2.7

Yes. You can first setup a virtualenv and then install supervisor use pip.

Create configuration file:

You can run multiple instances, just use different port supervisord listen on in configuration file:

python strip html tags like strip_tags in php

Earlier this week I needed to remove some HTML tags from a text, the target string was already recorded with HTML tags in the database and one of the requirement specifies that in some specific page we need to render it as a raw text.

I knew from the beginning that regular expressions could apply for that challenge, but since I am not an expert with regular expressions I looked for some advise in stack overflow and then I found what I actually needed.

Below is the function I have defined:

How to send requests through a Proxy in Python 3 using Requests

In this blog post we will show you how to send your requests to a website using a proxy, and then we’ll show you how to send these requests through multiple IP addresses or proxies.

How to send requests through a Proxy in Python 3 using Requests

If you are using Python-Requests, you can send requests through a proxy by configuring the proxies argument. For example

We’ll show how to send a real request through a free proxy.

How to check version of python modules

I suggest using pip in place of easy_install. With pip, you can list all installed packages and their versions with

In most linux systems, you can pipe this to grep to find the row for the particular package you’re interested in:

For an individual module, you can try the __version__ attribute, however there are modules without it:

Lastly, as the commands in your question are prefixed with sudo, it appears you’re installing to the global python environment. Strongly advise to take look into python virtual environment managers, for example virtualenvwrapper

Parse JSON – Convert from JSON to Python

If you have a JSON string, you can parse it by using the json.loads() method.

The result will be a Python dictionary.

Example

Convert from JSON to Python:


 

Convert from Python to JSON

If you have a Python object, you can convert it into a JSON string by using the json.dumps() method.

Example

Convert from Python to JSON:


 

Python Flask how to get parameters from a URL

In Flask, How do I extract parameters from a URL? How can I extract named parameters from a URL using flask and python?

When the user accesses this URL running on my flask app, I want the web service to be able to handle the parameters specified after the question mark:

Use request.args to get parsed contents of query string:

API URL will be as http://api.wpdemo.com/your-path?url=http://abc.com

Ref:

Ubuntu 16 default python is almost python 3

Loads of solutions exist, but for changing the system default, alias is not the way to go.

$ update-alternatives –list python update-alternatives: error: no alternatives for python

So we have 2 – use these in update-alernatives

Done

Flaskex – Simple flask for quick prototypes

Open source project written in Python.

We do not have to reinvent the wheel with features included:
  • Encrypted user authorizaton
  • Database initialization
  • New user signup
  • User login/logout
  • User settings
  • Modern user interface
  • Bulma framework
  • Limited custom css/js
  • Easily customizable

How to get it up in minutes