Code Monkey home page Code Monkey logo

sxcu's Introduction

This project is no longer maintained.

SXCU Python API Wrapper

sxcu PyPI Version sxcu Documentation Status sxcu codecov Total alerts Language grade: Python

sxcu-logo

A friendly API wrapper around https://sxcu.net.

Installation

The package is published on PyPI and can be installed by running:

pip install sxcu

Basic Use

Easily query the sxcu.net from you Python code. The data returned from the sxcu.net API is mapped to python resources:

>>> import sxcu
>>> con = sxcu.SXCU()
>>> con.upload_image("foo.jpg")
{'url': 'https://sxcu.net/2kW7IT', 'del_url': 'https://sxcu.net/d/2kW7IT/455c7e40-9e3b-43fa-a95a-ac17dd920e55', 'thumb': 'https://sxcu.net/t/2kW7IT.jpeg'}

Ready for more? Look at our whole documentation on Read The Docs.

Contributing

Please refer to CONTRIBUTING.md file for more information on how to contribute to this project.

All Contributors

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Naveen M K

πŸ’» πŸ“– 🚧 πŸ“† πŸ‘€ ⚠️ πŸ“¦

shahprog

πŸ› πŸ’»

Hexiro

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

sxcu's People

Contributors

allcontributors[bot] avatar dependabot-preview[bot] avatar dependabot[bot] avatar hexiro avatar naveen521kk avatar pre-commit-ci[bot] avatar shahriyardx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sxcu's Issues

Implement Logging

Logging is necessary and can be done easily using the default logging module. This would help to debug errors. A new class for logging would do.

Some More examples

Hey bro Can you pls share some more examples like this (I Don't know much about pythonπŸ˜…(
import sxcu
connector = sxcu.SXCU()
result = connector.upload_image("foo.png")
print(result["url"])

For subdomain
And If you are on Telegram can you pls share you id

Passing image content as parameter rather then image file path

Location

as can be seen here (and some other places)

with open(file, "rb") as img_file:
    files = {"file": img_file}
    res = request_handler.post(url, files=files, data=data)

The Problem

The wrapper accepts file paths over the file's content itself and then handles reading from that path. This is a problem when a user gets an image dynamically from some algorithm because then they have to write to the disk and supply that file path (not only slow but can cause errors based on permissions and os differences).

The Solution

possible solutions include:

  • Make the user handle reading from files.
  • having two separate parameters, one being path another being file content and expecting exactly one.
  • have one parameter, file_or_path which is handled differently based on its data type (bytes == file content, string == file path)

I'd be willing to make a PR if you know which solution you'd like to choose. In my opinion, now is a good time to change something like this because the API is already changing a lot due to v1 being deprecated. Let me know what you think :)

Check whether image is valid

Currently, the image file specified is just uploaded no matter what is it. Add a check for it and raise a Value error when it is invalid.

Handling Server Errors

Currently, the error response leads to JSON decode error. It should not happen and it must be handled by reading status code and custom errors must be raised.

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.