Skip to main content

A tiny web-server app with a configuration file, NO NEED TO CODE

Project description

Dynamic Command WebServer (dycow)

A tiny web-server app with a configuration file, NO NEED TO CODE

dycow-demo

Introduction

This project is a small webserver that just have to get a port and a configuration file to perform preconfigurated commands.

Disclaimer

This was a test-research project for a specific user-case on my raspberry-pi, therefore, i configurated only two methods (GET and POST)

Why use dycow

  • It's fast
  • Simple to configure, you just have to create a conf file to be ready to start
  • It's lightweight (The wheel is ~5Kb)

Requirements

  • Python (3.x recommend)

How to install

You just have to run :

pip install dycow

How to use

$ dw -h

[x] Help center !
[x] Run : dw <port> <conf-file> 
[x] Documentation online https://github.com/sanix-darker/dycow

You have to create a file, for example conf and set actions :

- GET /
res: Hello world

- GET /list
cmd: ls -l
res: #cmd#

- GET /callme?name&content
cmd: echo 'Hello #name#, #content#'
res: Thanks #name# !

- POST /save
var: name, content
cmd: echo '#content#' > #name#.txt

- GET(or - POST) is the type of the request, just after it the endPoint (/save, /callme?name&content).
cmd is the command line that will be executed on a request.
res[NOT REQUIRED] is the response to the request.
var is to specify POST variables. \

Variables like #content# means, the content variable will be replace with the input value as parameter.

  • Then run the server application:
# dw <port> <configuration-file>
dw 3000 conf

It will start a small server on port 3000 and following rules you specified in the configuration file.

Tests

To run rest-api tests, i made a bash file in ./tests directory.
you just have to run bash ./tests/rest-api-test.sh

$ bash ./tests/rest-api-test.sh 
[-] Running Endpoints tests on dycow.
[✓] GET / passed.
[✓] GET /list passed.
[✓] GET /callme?name=darker passed.
[✓] POST /save passed.
[-] Stopping tests Endpoints on dycow.

Author

LICENSE

Project details


Download files

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

Source Distribution

dycow-0.0.9.3.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

dycow-0.0.9.3-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page