simple web server
https://blog.anvileight.com/posts/simple-python-http-server/
【Python】AES暗号化
from Crypto.Cipher import AES import binascii #print(binascii.hexlify(uuid.uuid4().bytes)) secret_key = ‘abcdefghijklmnop’ message = ‘1234567890abcdef’ crypto = AES.new(secret_key) cipher_data = crypto.encrypt(message) print(binascii.hexlify(bytearray(cipher_data)))
【python】exif tag
import os from PIL import Image from PIL.ExifTags import TAGS,GPSTAGS from os import path class Point: def __init__(self, lat, lon,
【Python3】コンパイル
python -m compileall xxx.py
【Python3】sftp
paramiko pip install paramiko PythonでSSH接続とSFTPファイル転送
【Python3】HTTP GET (requests)
pip install requests import requests _url = ‘http://xx.com/a.mp4’ r = requests.get(_url, auth=(_user,_pass), stream=True) try: if r.status_code == 200: f =
【python】pyOSC
python -m pip install –upgrade pip pip install pyosc c:\Python27\Scripts>pip.exe install pyosc
【python】Windows + pynfc
相当しんどいWindowのpynfc http://nfcpy.readthedocs.io/en/latest/topics/get-started.html python 2系をインストール。pynfcは2系。 システム環境変数Pathにc:\Python27を追加。 pip実行してlibusb,pyserial取得 C:\Python27\Scripts\pip.exe install libusb1 pyserial ・WinUSBドライバと、libusb-1.0.dllをSystem32へコピー Zadigをinstall Zadigを起動して、menu>Option> List All Devicesをチェック
【Html】 Http Post/Get
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Sending_and_retrieving_form_data
uWSGI –help
uwsgi –help Usage: /Users/mknod/.pyenv/versions/3.5.1/bin/uwsgi [options…] -s|–socket bind to the specified UNIX/TCP socket using default protocol -s|–uwsgi-socket bind to the specified
【MondoDB】パスワード暗号化
import hashlib from passlib.hash import pbkdf2_sha256 print(hashlib.algorithms_available) print(hashlib.algorithms_guaranteed) password =’abcd1234′ # hash _hash = pbkdf2_sha256.encrypt(password, rounds=200000, salt_size=16) print(_hash) #save
【MongoDB】 検索
検索 cli = MongoClient() db = cli.sample _datas = list(_col.find()) _datas = list(_col.find({})) #上に同じ _datas = list(_col.find({‘temp’:’10’})) # temp=10 _datas
【Python3】dictionary
キーが存在するかどうか _data = { ‘keyname’, ‘1234’ } if ‘keyname’ in _data: … True/False
Check Server Security
サーバーセキュリティランク付け https://www.ssllabs.com/ssltest/ コンテンツランク付け https://securityheaders.io/
Protected: SSL証明書(certbot)と、Nginxの設定
There is no excerpt because this is a protected post.
nginx+uWSGI+bottle
ubuntu 14.04 【install】 sudo apt-get -y update sudo apt-get -y upgrade sudo apt-get dist-upgrade -y sudo apt-get -y install build-essential
REST test script
from bottle import route, run, template,get,post,put,delete,request,response import json import os def secure_response_headers(response): response.set_header(‘Content-Type’, ‘application/json’) response.set_header(‘X-XSS-Protection’, ‘1; mode=block’) response.set_header(‘X-Frame-Options’, ‘deny’) response.set_header(‘Content-Security-Policy’,