This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gunicorn, or Green Unicorn, is a UNIX-compatible WSGI HTTP server that is commonly used to run Python applications. | |
Developed in 2010 by Benoit Chesneau, this open source project is similar to uWSGI, mod_wsgi, and CherryPy. | |
Gunicorn is often implemented with a reverse proxy server like NGINX, which typically handles requests for static resources and then passes on the requests to Gunicorn. | |
Gunicorn processes the dynamic portion of the request and returns a response to NGINX, which sends the response back to the client. | |
Gunicorn can be used to serve Python applications and is compatible with frameworks like Django, Flask and Bottle. | |
It’s easy to configure, lightweight, and only needs 4–12 worker processes to handle hundreds or thousands of requests per second. | |
# create python3 virtual environment | |
# ================================== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
#Ref: https://www.ictshore.com/python/python-ping-tutorial/ | |
#Ref: https://stackoverflow.com/questions/58330533/how-to-handle-error-exceptions-with-pythonping | |
#Ref: https://kite.com/python/docs/csv.DictWriter.writerows | |
from pythonping import ping | |
import socket | |
import csv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Sun Jan 26 09:43:37 2020 | |
@author: bockor | |
https://stackoverflow.com/questions/30862099/how-can-i-get-certificate-issuer-information-in-python | |
https://gist.github.com/ryansb/d8c333eb4a74168474c4 | |
https://kite.com/python/docs/ssl.SSLSocket.getpeercert |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
''' | |
[ | |
{ | |
"20S301": "SHAPE", | |
"20SU06": "SHAPE", | |
"77B301": "BRUNSSUM", | |
"77B302": "BRUNSSUM", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
## PING | |
#Ref: https://www.ictshore.com/python/python-ping-tutorial/ | |
#Ref: https://stackoverflow.com/questions/58330533/how-to-handle-error-exceptions-with-pythonping | |
## CSV | |
#Ref: https://kite.com/python/docs/csv.DictWriter.writerows |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[DEFAULT] | |
DEBUG = True | |
domaindb_file = ./dummy_data/dummy_domaindb.json | |
servers_file = ./dummy_data/dummy_servers.json | |
#WSGI Server | |
host = 101.135.27.63 | |
port = 8080 | |
debug = True | |
reloader = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Ref: https://community.infoblox.com/t5/DNS-DHCP-IPAM/WAPI-Web-API-Sample-Code-for-NIOS/m-p/105/highlight/true#M12 | |
Sample -- sample python application for WAPI | |
''' | |
import sys | |
import json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -type f -name "*.py[co]" -delete -or -type d -name "__pycache__" -delete |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
***************************************************** | |
*** APPROACH 1: install uwsgi as a system package *** | |
***************************************************** | |
install packages | |
---------------- | |
apt install uwsgi uwsgi-plugin-python3 | |
Configure uwsgi daemon | |
---------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://hub.docker.com/r/d3fk/python_in_bottle/ | |
docker pull d3fk/python_in_bottle | |
docker run -itd --name nra_site_inventory --rm -p 8080:8080 -v $(pwd)/yEd-SiteInventory:/usr/src/myapp -w /usr/src/myapp d3fk/python_in_bottle:latest python site_inventory.py | |
# This prevents Python from writing out pyc files | |
docker run -itd --name nra_site_inventory --rm -e PYTHONDONTWRITEBYTECODE="1" -p 8080:8080 -v $(pwd)/yEd-SiteInventory:/usr/src/myapp -w /usr/src/myapp d3fk/python_in_bottle:latest python site_inventory.py | |
docker stop nra_site_inventory |
OlderNewer