Skip to main content

Asynchronous functions for making HTTP requests to Gancio istances

Project description

gancio_requests

gancio_requests is a tool for making asynchronous HTTP requests to the API of a specified Gancio instance. Gancio is a shared agenda for local communities, a project which wants to provide a self-hosted solution to host and organize events.

This repo aims to supply a convenient set of functions to fetch data from a gancio instance (e.g. scheduled events, the image or description of an event).

Installation

To install the latest version of the library just download (or clone) the current project, open a terminal and run the following commands:

pip install -r requirements.txt
pip install .

Alternatively use pip

pip install gancio_requests

Dependencies

At the moment I have tested the library only on python == 3.10.4

The library requires the dependencies specified in requirements.txt and I haven't still tested other versions.

Usage

Command line interface

python3 -m gancio_requests [-h] gancio_instance

gancio_instance is the URL of the instance from which we want to fetch the data.

The output displays the list of events starting of 00:00:00 of the current day. The information about an event is shown this way:

EVENT_NAME
[STARTING_TIME | END_TIME]
PLACE_NAME - ADDRESS
LIST_OF_TAGS (optional)
EVENT_URL

Example

Input
python3 -m gancio_requests https://gancio.cisti.org
Output
Crazy toga party
[2022-08-11 22:30:00 | 2022-08-12 00:00:00]
Colosseo - Piazza del Colosseo, Roma
Tags: ["colosseum", "ancient rome", "toga party"]
https://gancio.cisti.org/crazy-toga-party

Gioco del ponte
[2022-09-10 22:00:00 | 2022-09-10 23:00:00]
Ponte di mezzo - Ponte di Mezzo, 1, 56125 Pisa
https://gancio.cisti.org/gioco-del-ponte

Python library

After the installation, it is possible to use the package directly from the python interpreter by using import gancio_requests.

Caching

It is possible to cache HTTP requests thanks to aiohttp-client-cache. All the functions shown above have an optional parameter called cache which accepts a aiohttp_client_cache.backends object.

import asyncio
from aiohttp_client_cache import SQLiteBackend
from gancio_requests.request import get_events

url = 'https://gancio.cisti.org'
params = {"start": 0}
cache = SQLiteBackend(
    cache_name = "Test.db"
)
result = asyncio.run(get_events(url, params, cache=cache)) 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gancio_requests-0.1.2.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gancio_requests-0.1.2-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file gancio_requests-0.1.2.tar.gz.

File metadata

  • Download URL: gancio_requests-0.1.2.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.4

File hashes

Hashes for gancio_requests-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4ec0019c73230b449aa1cf7797bfa86cd3ed98dcab3c33aa11c2776744a8214e
MD5 f8791779aefd82fb65850be543e4206a
BLAKE2b-256 4986187ef8a3bfa46fcea775378703b09f663e5f1c1c73a82dac17fae160be4c

See more details on using hashes here.

File details

Details for the file gancio_requests-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: gancio_requests-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.4

File hashes

Hashes for gancio_requests-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f4142760e36e49ac2f8b6671a99805e5540decd001611c3a80970667e357bfa6
MD5 93c40cc08b5820084a485a9f5fd8de3c
BLAKE2b-256 d486804b70fc3b46b5ab1448fba310073b4b51231c966c361523cf4671c9c172

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page