GithubHelp home page GithubHelp logo

wallvon / mofh Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 3.0 51 KB

An API client for MyOwnFreeHost in Python

Home Page: https://mofh.readthedocs.io

License: GNU General Public License v3.0

Python 100.00%
mofh myownfreehost vpanel vistapanel byethost ifastnet byet python python3 free-hosting freehosting async asynchronous async-await

mofh's Introduction

License Compatible Python versions PyPi monthly downloads PyPi version

Tests

mofh by Robert S.

An API wrapper for MyOwnFreeHost.

Installation

To install from PyPi run

pip install mofh

Documentation

https://mofh.readthedocs.io

Versioning

mofh uses the following versioning pattern:

major.minor.patch

  • Major: Breaking changes, the bot is no longer compatible with previous versions.
  • Minor: New features, no breaking changes.
  • Patch: Bug fixes and small improvements.

Usage

Basic usage (creating an account)

Sync:

import mofh

# With a context manager
with mofh.Client(username="example", password="password") as client:
    response = client.create(username='example', password='password', contactemail='[email protected]',
                         domain='subdomain.example.com', plan='MyAwesomePlan')
    print(response)

# ---

# Without a context manager
client = mofh.Client(username="example", password="password")

response = client.create(username='example', password='password', contactemail='[email protected]',
                         domain='subdomain.example.com', plan='MyAwesomePlan')
print(response)

client.close()

Async:

import mofh

# With a context manager
async with mofh.AsyncClient(username="example", password="password") as client:
    response = await client.create(username='example', password='password', contactemail='[email protected]',
                         domain='subdomain.example.com', plan='MyAwesomePlan')
    print(response)

# ---

# Without a context manager
client = mofh.AsyncClient(username="example", password="password")

response = await client.create(username='example', password='password', contactemail='[email protected]',
                         domain='subdomain.example.com', plan='MyAwesomePlan')
print(response)

await client.close()

Custom session

It is possible to use custom requests or aiohttp session with configured timeouts and other settings.

Sync:

import mofh
from requests import Session

client = mofh.Client(username="example", password="password", session=Session())

Async:

import mofh
from aiohttp import ClientSession, ClientTimeout

client = mofh.AsyncClient(username="example", password="password", session=ClientSession(timeout=ClientTimeout))

Custom API URL

In case URL gets changed for some reason it is possible to overwrite the API URL:

import mofh

client = mofh.Client(username="example", password="password", api_url="https://panel.myownfreehost.net/xml-api/")

mofh's People

Contributors

dependabot[bot] avatar durof avatar wallvon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mofh's Issues

Add support for callbacks

This is just an idea for now, but perhaps I could add support for callbacks by integrating some kind of handler for the user's web (micro)framework of choice.

Re-do documentation

The current documentation is ugly, doesn't work well and doesn't really show anything which results in users having to look through the source code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.