Skip to content

Instantly share code, notes, and snippets.

View imgVOID's full-sized avatar
🎯
Focusing

Maria Hl. imgVOID

🎯
Focusing
View GitHub Profile
@imgVOID
imgVOID / settings.py
Created June 5, 2020 14:15 — forked from drivard/settings.py
Django basic settings.py with sqlite3 database
# Django settings for myproject project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
execute_js(
library_list,
main_function,
data_dict={},
callbacks={},
css_list=[],
)
# Установка ссылки на библиотеку D3:
d3_lib_url = "https://d3js.org/d3.v3.min.js"
# Определение JavaScript-функции при помощи Python-строки:
js_string = “””
function draw_circle(div_id, data){
d3.select(div_id)
.append("div")
.style("width", "50px")
.style("height", "50px")
# Указание ссылки на библиотеку D3:
d3_lib_url = "https://d3js.org/d3.v3.min.js"
# Загрузка локальных библиотек:
with open("radial_bar.css", "r") as f:
radial_bar_css = f.read()
with open ("radial_bar_lib.js", "r") as f:
radial_bar_lib = f.read()
helloworld_js = """
function helloworld(div_id, data){
comm = new CommAPI("get_hello", (ret) => {
document.querySelector(div_id).textContent = ret.text;
});
setInterval(() => {comm.call({})}, 1000);
comm.call({});
}
"""
import random
def hello_world_random(data):
hello_world_languages = [
"Ola Mundo", # Португальский
"Hello World", # Английский
"Hola Mundo", # Испанский
"Geiá sou Kósme", # Греческий
"Kon'nichiwa sekai", # Японский
"Hallo Welt", # Немецкий
"namaste duniya" # Хинди
from notebookjs import execute_js
execute_js(helloworld_js, "helloworld", callbacks={"get_hello": hello_world_random})
<article class ="main-article">
<h1> Титаник(1997) </h1>
<p class ="plot" > 84 года спустя... </p>
<div class ="full-script">
"13 метров. Можешь сам посмотреть. "
<br>
"Хорошо, поднимите её и перекиньте через носовой поручень. "
<br>
...
</div>
from bs4 import BeautifulSoup
import requests
root = 'https://subslikescript.com'
website = f'{root}/movies'
result = requests.get(website)
content = result.text
soup = BeautifulSoup(content, 'lxml')
box = soup.find('article', class_='main-article')
@imgVOID
imgVOID / class_based_middleware.py
Last active August 11, 2021 18:18 — forked from Akash1362000/class_based_middleware.py
Пользовательский Django Middleware на основе класса
class ExampleMiddleware:
def _init_(self, get_response):
self.get_response = get_response
def _call_(self, request):
# Код, вызываемый перед представлением при каждом запросе.
response = self.get_response(request)