Skip to content

Instantly share code, notes, and snippets.

View nobbynobbs's full-sized avatar
👀
who's there?

Roman nobbynobbs

👀
who's there?
  • Nizhny Novgorod, Russia
View GitHub Profile
@nobbynobbs
nobbynobbs / app.py
Created April 30, 2019 16:23
aiohttp-server-and-session
from aiohttp import web, ClientSession
from aiohttp.web import middleware
async def search(request):
q = request.query.get("q", "")
session = request.app["client_session"]
async with session.get("https://ya.ru", params={"q": q}) as request:
body = await request.read()
return web.Response(body=body, headers={"content-type": "text/html"})
@nobbynobbs
nobbynobbs / q50550830.py
Last active May 27, 2018 11:27
answer for stackoverflow
import lxml.etree as ET
import csv
# load file
tree = ET.parse('users.xml')
# iterate through each user tag
users = tree.findall('.//user')
all_roles = list({role.find('name').text for role in tree.findall('.//role')})
# just w mode, no wb. wb for binary data
with open('user_list.csv', "w") as csv_file:
@nobbynobbs
nobbynobbs / main.py
Last active January 23, 2020 21:37
Marshmallow nested Schema
"""
dependencies:
flask = "^1.1.1"
flask_marshmallow = "^0.10.1"
flask_sqlalchemy = "^2.4.1"
marshmallow-sqlalchemy = "^0.21.0"
"""
import sys