Uvicorn

Uvicorn is a lightning-fast ASGI server used to serve python ASGI frameworks like FastAPI, Django Channels, Quart, BlackSheep, etc… https://www.uvicorn.org To install Uvicorn, run

To run, you can use

See Python […]

Read More…

Flask Python framework

Flask is a Python framework. You can find more info at the official website. https://flask.palletsprojects.com/ How to start a Flask application? To start flask application, run

How to run flask application on port 80 To run flask application on port 80, use command

Or edit app.py, use the following code

Or you […]

Read More…

Install Python 3.8 on CentOS 6 from source

To install Python 3.8 on CentOS, you need to install OpenSSL as the one installed by CentOS from yum is very old.

Now edit file

at end of the file, add

Make the settings active with command

Now we can install Python 3.8 with

Now python 3.8 will be available […]

Read More…

Python mechanize HTTP Error 403 request disallowed by robots.txt

When running following python script i get error “HTTP Error 403 request disallowed by robots.txt”

To fix this, find

Add below

set_handle_robots is used to disable robots.txt checking. Second line will set a User-agent, so remote won’t won’t block you as a robot. See Python […]

Read More…

error: Python.h: No such file or directory

When install dlib python module, i get error

This is because missing python3-dev package. To fix, install

If you are using python virtualenv, you will need to recreate the virtualenv after installing dev package.

[…]

Read More…

ERROR: Failed building wheel for mysqlclient

When install mysqlclient python module, i get error

Fixed by installing

[…]

Read More…

pip install mysqlclient mysql_config: not found

On Ubuntu 18.04, when i install mysqlclient python module, i get error

this is fixed by installing libmysqlclient-dev

ERROR: Failed building wheel for mysqlclient See Python […]

Read More…

Installing PyCharm Community Edition on Ubuntu

pycharm python editor

PyCharm Community Edition is a free python editor from JetBrains. You can download it from https://www.jetbrains.com/pycharm/download/#section=linux Download and extact the tar.gz file. Move it to a folder like

Execute sartup script

Once pycharm started, you can go to Tools menu and create a startup script. […]

Read More…

Running Web Server with python SimpleHTTPServer

SimpleHTTPServer is a python module that allow you to run web server for static files. To start web server, run

This will start a web server on port 8000. You will be able to access server in URL

To stop server, press CTRL + C To get SimpleHTTPServer run on differnt port, run […]

Read More…

Create Python Flask Docker Container

Create a folder and change to the folder

Create file

Add following content

Create file requirements.txt, add “Flask” to it.

Now lets create our Python Flask Application

Add following content

To test Flask application locally, install Flask using pip

Now run the application using

Now you will […]

Read More…