Skip to main content

Wellcome to apys! A simple backend restful framework!

LANGUAGE

Python >= 3.4.2

LIBRARIES

  • aiohttp - http client/server for asyncio


INSTALATION

  1. Install python 3

    • Windows - Link

    • Ubuntu - sudo apt-get install python

    • Fedora - sudo yum install python

    • Arch - sudo pacman -S python

  2. Install PIP - Python libraries manager

    • Windows - Link

    • Ubuntu - sudo apt-get install pip

    • Fedora - sudo yum install pip

    • Arch - sudo pacman -S pip

  3. Install this framework using PIP

    • pip install apys


INITIALIZATING PROJECT

$ apys --init

USING

DIRECTORIES

/config - json configuration files
/endpoints - backend endpoints
/utils - helper script files

CONFIG

Here are the configuration files used in the app. They will be send to the endpoint via param api.config

There are 3 special filenames: * prod.json - The oficial configuration file * dev.json - The development configuration file * local.json - The local configuration file (ignore in git)

Note: They really work as following: the api tries to load local.json, then dev.json, then prod.json. So in the oficial release you will only have prod.json

The current config special properties are the following:

{
    "log": bool, //optional. default=False
    "server": {
        "port": int, //optional. default=8888
        "cors": string or False //optional. default=False
    },
    "mail": {
        "host": string,
        "port": int, //optional. default=25 or 587 for TLS
        "tls": bool, //optional. default=False
        "username?": string, //optional. no default
        "password?": string //optional. no default
    }
}

ENDPOINTS

This will be your main dev dir

All files added here will be an endpoint automatically

i.e.: the file endpoints/hello/world.py will generate an endpoint /hello/world

The file’s code will be the following:

utils = [
    '[util1]',
    '[util2]'
]

def [method](req, api):
    [process]

Where [method] is the http request type: * post * get * put * delete * head * options * default - executed when a request is made for any of the above, but it is not implemented

[process] is what you wan the endpoint to do (your code)

[util1] and [util2] are the utils scripts (without .py)

req is aiohttp’s request, documentation

req has the param property to read the request body

api is the object that contains all api functionalities: * config - Configuration dictionary used in the actual scope * debug - function to log messages * error - function to log errors

UTILS

Python files with reusable code, to be called on endpoints.

It will be a normal cod, but with some special funcions:

init(api)

The function that will be executed on server startup
Only one time.

[method](req, api) - [method] being the type of http request

The function that will be called before every request to the function with the same name on the endpoint.
Any result should be stored on the variable `req`, because it is the only local variable on the request.

any(req, api)

The function that will be executed before any request.
Note: thids function will be executed before the later.

EXAMPLE

Look at the demos/ for examples


STARTING THE SERVER

There are 2 ways to start the server

  1. Execute apys -s from terminal on your root project folder (Recomended)

  2. Call the method start() from module apys.server (Only recomended if you need to do something before starting the server)


OBSERVATION

Both the framework and this page are in development, so, subjected to changes.

Version previous to v0.1.0 vas called pypolyback and used python 2.

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

apys-0.2.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file apys-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: apys-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for apys-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4bd6cb6b79036ff46a4761c3c669d37c4b1e83e018eadf1b31f6426caff9415
MD5 b5f2528cc2b463b236665039fd793c04
BLAKE2b-256 b93f26772db92cbfc14c6492f00c77675b550dca5950a1aa43a006d70581a71a

See more details on using hashes here.

Release history Release notifications | RSS feed

3.2.1

2 files

3.1.5

2 files

3.1.4

2 files

3.1.2

1 file

3.1.1

1 file

3.1.0

1 file

3.0.0

1 file

2.2.2

1 file

2.2.1

1 file

2.2.0

1 file

2.1.1

1 file

2.1.0

1 file

2.0.1

1 file

2.0.0

1 file

1.0.1

1 file

1.0.0

1 file

0.6.3

1 file

0.6.2

1 file

0.6.1

1 file

0.6.0

1 file

0.5.3

1 file

0.5.2

1 file

0.5.1

1 file

0.5.0

1 file

0.4.3

1 file

0.4.2

1 file

0.4.1

1 file

0.4.0

1 file

0.3.2

1 file

0.3.1

1 file

0.3.0

1 file

0.2.3

1 file

0.2.2

1 file

0.2.1

1 file

This release

0.2.0 This release

1 file

0.1.6

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page