[sync] updated: config based; async loop; Documents adopted to new system

This commit is contained in:
Roman Timashev committed 2017-09-10 22:12:09 +03:00
1 parent b0b518fd8c
commit 06965bebee
23 files changed
+1078 -346

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
import aiohttp
import requests
import settings
async def upload(url, path):
"""
:param url:
:param path:
:return:
"""
if not settings.upload_enabled:
return url
# urlf = 'https://static.shlisselburg.org/upload/art{}'
files = {'file': open(path, 'rb')}
r = requests.put(
url=url,
files=files,
# auth=settings.upload_auth
auth=('uploader', '1207690962638465')
)
if r.status_code == 200:
return url
else:
return None
async def get(url):
async with aiohttp.ClientSession as session:
res = session.get(url)
return await res.text()
async def put(url, data):
async with aiohttp.ClientSession as session:
res = session.put(url, data=data)
return await res.text()