Skip to content

Instantly share code, notes, and snippets.

View morlandi's full-sized avatar

morlandi morlandi

View GitHub Profile
@morlandi
morlandi / parse_html.py
Created January 7, 2021 11:50
Parsing HTML in a Django unit test with BeatifulSoap
from bs4 import BeautifulSoup
def check_diary_table_disabled(self, response):
"""
Parse #diary-table from HTML, and check for 'disabled' class
"""
html = BeautifulSoup(response.content, features="lxml")
diary_table = html.find('table', {'id': 'diary-table', }, recursive=True)
diary_table_attrs = diary_table.attrs
self.assertIn('class', diary_table_attrs)
@morlandi
morlandi / simple_mjpeg_streamer_http_server
Created January 17, 2020 07:53 — forked from n3wtron/simple_mjpeg_streamer_http_server
Simple Python Motion Jpeg (mjpeg server) from webcam. Using: OpenCV,BaseHTTPServer
#!/usr/bin/python
'''
Author: Igor Maculan - n3wtron@gmail.com
A Simple mjpg stream http server
'''
import cv2
import Image
import threading
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
from SocketServer import ThreadingMixIn
# -*- coding: UTF-8 -*-
import signal
import sys
import traceback
import time
import logging
import json
import channels.layers
from asgiref.sync import async_to_sync
from channels.db import database_sync_to_async