Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Wellcome to apys! A simple backend restful framework!
sudo apt-get install python
sudo yum install python
sudo pacman -S python
sudo apt-get install pip
sudo yum install pip
sudo pacman -S pip
pip install apys
$ apys --init
/config - json configuration files
/endpoints - backend endpoints
/filters - script files to execute before the endpoint
/utils - script files to execute when server starts
Here are the configuration files used in the app.
They will be send to the endpoint via param api.config
There are 3 special file names:
prod.json
- The production configuration filedev.json
- The development configuration filelocal.json
- The local configuration file (ignore in git)You can also force it to use a configuration with the --config
or -c
option:
$ apys -s --config=my_config
Note: If no config file is chosen, they will work as following: the api tries to load
local.json
, thendev.json
, thenprod.json
The current config special properties are the following:
{
"log": {
"file": {
"debug": "string or false //default=false. debug log file, false for sys.stdout",
"error": "string or false //default=false. debug error file, false for sys.stderr",
"(...)": "string or false //optional. you can specify any other log file, but you will have to tell the `api.debug` function to use it"
},
"color": "bool //default=true"
},
"server": {
"port": "int //default=8080",
"cors": "string or false //default=false"
},
"utils": ["string //default=[]. list of utils in order to load"],
"(...)": "(...) //you can add any other key and access it via `api.config['my_key']`"
}
You can also use environment variables
like $PORT
(for PORT
env var), and set a default value if no env var is found
like $PORT|8080
or $PORT|8080|int
(if type is needed)
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:
filters = [
'filter1',
['filter2', 'filter3']
]
def method(req, api):
pass # process
Where method
is the http request type:
process
is what you wan the endpoint to do (your code)
filter1
, filter2
and filter3
are the filters scripts (without .py
) executed before the endpoint is called
If you put your filter inside an array the error they return will be returned only if ALL of them return some error
req
is aiohttp's request, documentation
req
's propertybody
only works for json works as of now
api
is the object that contains all api functionalities:
Also api.web
contains aiohttp.web
Code that will that will be called before every request.
method
(req, api) - method
being the type of http request
The function that will be executed 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.
always(req, api)
The function that will be executed before any request.
Note: this function will be executed before the other filters.
Python files special functionality.
It needs to be inside a dir and has some special files
This file contains a function that will be called before initializing the api.
def init(api):
pass
The function that will be executed on server startup
Only one time.
Useful for setting some api constants
This file contains a function that will add a commandline argument.
The util flags will be --[util_name]
and --[util_name_first_char]
util name is test, so flags should be
--test
and-t
class CLI:
def __init__(self, result):
# See `parser.add_argument` doc for information on these
self.action = 'store_true'
self.default = False
self.help = 'It makes everything shine'
# store the result of user input
self.result = result
def start(self, api, endpoints):
pass
Look at the demos/
for examples:
hello_world
: a simple hello world app, to learn the basicscalculator
: a simpler app that resembles more a normal productlog_to_file
: an example of logging in filesuser_role
: an advanced example on filtersunit_testing
: an advanced example on adding cli argumentsThere are 2 ways to start the server
Execute apys -s
from terminal on your root project folder (Recommended)
Call the method start()
from module apys.server
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.
FAQs
A simple back-end rest framework in python using aiohttp lib
We found that apys demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.