This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| dependencies: | |
| flask = "^1.1.1" | |
| flask_marshmallow = "^0.10.1" | |
| flask_sqlalchemy = "^2.4.1" | |
| marshmallow-sqlalchemy = "^0.21.0" | |
| """ | |
| import sys |
NewerOlder