Default aiohttp static handler doesn't support any modification on the fly.
This handler helps to serve static files from directory ./static as is and convert JSX for ReactJS if needed.
import asyncio
import logging
from aiohttp import web
import osDefault aiohttp static handler doesn't support any modification on the fly.
This handler helps to serve static files from directory ./static as is and convert JSX for ReactJS if needed.
import asyncio
import logging
from aiohttp import web
import os| engine = DjangoTemplates( | |
| { | |
| 'NAME': 'mail', | |
| 'APP_DIRS': False, | |
| 'DIRS': [], | |
| 'OPTIONS': { | |
| 'loaders': [ | |
| 'events.loaders.MyLoader', | |
| ], | |
| }, |
| from rx import Observable, AnonymousObservable | |
| from rx.concurrency import current_thread_scheduler | |
| from rx.internal import extensionclassmethod | |
| @extensionclassmethod(Observable) | |
| def from_iterable_with_interval(cls, period, iterable, scheduler=None): | |
| """Creates an Observable that polls iterator made from iterable every period millis.""" | |
| iterator = iter(iterable) | |
| return Observable.interval(period, scheduler=scheduler).map(lambda v: next(iterator)) |
| # coding: utf8 | |
| def dijkstra_shortest_path(graph, start, paths={}, visited=[]): | |
| if len(paths) == 0: | |
| paths[start] = {'dist': 0, 'parent': None} # инициализация начального пути | |
| # print "start V: %d, " % (start) | |
| for x in graph[start]: | |
| if (x not in visited and x != start): | |
| if (x not in paths.keys() or (graph[start][x] + paths[start]['dist']) < paths[x]['dist']): | |
| paths.setdefault(x, {'dist': 0, 'parent': None}) | |
| paths[x]['dist'] = graph[start][x] + paths[start]['dist'] |
| import psutil | |
| import requests | |
| def open_files(): | |
| proc = psutil.Process() | |
| return proc.open_files() | |
| print 'on start:', open_files() |
| # https://stackoverflow.com/questions/36384353/generate-pixel-matrices-from-characters-in-string | |
| # FONT: https://fontstruct.com/fontstructions/show/1404190/cg-pixel-4x5-1 | |
| from PIL import Image | |
| from PIL import ImageFont | |
| from PIL import ImageDraw | |
| import numpy as np | |
| def char_to_pixels(text, path, fontsize): | |
| font = ImageFont.truetype(path, fontsize) |