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…

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…

Running Python Application with gunicorn and nginx

Create a service file for gunicorn

Here /home/ubuntu/myapp/wagtail2 = path to the folder where web application is. /home/ubuntu/myapp/venv/bin/gunicorn = is where gunicorn installed inside virtualenv. Change these path as required. Restart gunicorn with

use following nginx config

Restart nginx

[…]

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…

Getting started with Django Framework

Django is a python framework for developing web applications. To install Django, run

To create a project, run

Django come with built in development server. To start Django development server, change to the project folder and run

It will start a development web server on url http://127.0.0.1:8000/ Creating App A django project […]

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…