Giter VIP home page Giter VIP logo

python-neocities's Introduction

python-neocities - Python API for NeoCities.org

python-neocities is a Python wrapper of the NeoCities.org REST API.

NeoCities.org is a FLOSS service which offers 20 Megabytes of gratis and ad-free hosting inspired by GeoCities. I really liked their approach so I decided to contribute this little API.

To install it, type python setup.py install or make install.

The unit tests rely on having a NeoCities.org account. To run them, type

NEOCITIES_USER=user NEOCITIES_PASS=pass make test

But then again, I wouldn't recommend running them at all since they might make you seem suspicious to NC's admins and the API is simple enough.

Usage

First, you must initialize a NeoCities object with

import neocities

nc = neocities.NeoCities('username', 'password')

Or you can initialize a NeoCities object using an API key with

import neocities

nc = neocities.NeoCities(api_key='NEOCITIES_API_KEY')

(Passing a valid username and password, or API key, is not necessary if you are only going to use the info call)

After you've done that, you can query NeoCities for information about a specific site with:

response = nc.info('sitename')

If you have provided correct login credentials, you can also query NeoCities for your own site's info with

response = nc.info()

You can upload files with

nc.upload(('name_on_disk', 'name_on_server'), ...)

Where name_on_server is the name you want the file to have on the NeoCities server and name_on_disk is the name (path) of the file on your disk.

You can delete a file remotely with

nc.delete('filename1', ...)

To make sure you are not doing something wrong, the InvalidRequestError exception will be fired when you do. It has a status_code attribute which contains the status code returned by your request. For a list of status codes (useful to debug your requests), check out this Wikipedia page.

python-neocities's People

Watchers

 avatar  avatar

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.