Package: dummyrest
Dummy REST APITool for testing REST APIs Function1. Requirementspython >= 3.6python-dev >= 3.6pip3.61.1 Install python3.7 and pip3.7 on Debian system:Run as rootaptupdate
aptinstallgccgitpython3.7-minimalpython3.7-devpython3-pip-y
python3.7-mpipinstall--upgradepipNote that if you execute the last command withoutsudo,pip3.7is installed in directory/home/{username}/.local/binwhich might not be in thePATHvariable, depending on the distribution you are running. Add the directory to thePATHvariable in order to be able to use it.1.2 Install python3.7 and pip3.7 on CentOS > 7 system:Run as rootyum update -y
yum install -y epel-release && yum update -y
yum install -y gcc git python3 python3-devel python3-pip2. Installation2.1 PyPIpip3.7installdummyrest2.2 Githubgit clone https://github.com/medianetlab/dummyrest.git
cd dummyrest
sudo pip3.7 install .Note that if you execute the last command withoutsudo,dummyrestscript is installed in directory/home/{username}/.local/binwhich might not be in thePATHvariable, depending on the distribution you are running. Add the directory to thePATHvariable in order to be able to use it.3. UsageA new command has been installed. which starts the dummyrest application:dummyrestAdd the&at the end to run at the backgroundThe dummyrest application is listening by default on port8000. To check that the application has started run a curl requestcurl http://<IP>:8000/dummy. You should get a200response with the message"Dummy REST API". By default the application writes a log file at the home directory of the user that started the application.4. DatabaseA sample database to store the resources of the example REST API is supported by the application. You can set it to use an external database by setting theDB_URLenvironmental variable to the external databse URL before you start the application.If no external database url is given, the application will use a local SQLITE3 database. You can set the path for the local db file by setting theSQLITE_DB_PATHenvironmental variable before you start the application. If this variable is not set, by default the application will create the databse file on the home directory of the user that started the application, under the namedummyrest.db.5. Create a systemd serviceTo create a systemd service that will run the dummyrest application download the Github repository and run the script:sudo./systemd/create_serviceRunsystemctl status dummyrestto check if the service has started successfully. The logs are stored in/var/run/dummyrest/logs/dummyrest.log6. Use dummyrest with NGINX6.1 Install NGINX6.1.1 DebianRun as rootaptinstall-ynginx
systemctlstartnginx
systemctlenablenginx
systemctlstatusnginx6.1.2 CentOSRun as rootSet up the yum repository for RHEL or CentOS by creating the file nginx.repo:vim /etc/yum.repos.d/nginx.repo[nginx]name=nginxrepobaseurl=https://nginx.org/packages/mainline/centos/7/$basearch/gpgcheck=0enabled=1Install nginx:yumupdate-y
yuminstall-ynginx
systemctlstartnginx
systemctlenablenginx
systemctlstatusnginxIf the SELINUX is enabled, then it must be allowed to serve httpsemanagepermissive-ahttpd_t
systemctlreloadnginx6.2. Configure NNGINXRemove any default file in/etc/nginx/conf.d/or/etc/nginx/sites-enabled/directories and create the/etc/nginx/conf.d/dummyrest.conffile:server {
    listen 80 default_server;
    server_name _;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/var/www/html/dummyrest/socket.sock;
    }

    error_page 404 /404.html;
    location /404.html {
        root /usr/share/nginx/html;
    }

}Reload the nginx service:sudo systemctl reload nginxCreate the folder where the socket file will be saved:sudomkdir-p/var/www/html/dummyrest/
sudochown-R${USER}:${USER}/var/www/html/dummyrestRun thedummyrest-nginxscript to start serving the dummyrest application on port806.3 Create systemd service with nginxTo make create a systemd service using the nginx as webserver, configure the nginx as described above and run the script:./nginx/systemd/create_service.sh7. Available APIs7.1 DummyAPIMethodDataDescription/dummyGET-Get a list of all the items in the dummy resource/dummyPOSTJSONAdd a new item to the dummy resource/dummy/{id}GET-Get the item with id=id from the dummy resource/dummy/{id}POSTJSONCreate an item with id=id from the dummy resource/dummy/{id}PUTJSONUpdate or create the item with id=id from the dummy resource/dummy/{id}DELETE-Delete the item with id=id from the dummy resource7.2 BooksAPIMethodDataDescription/booksGET-Get a list of all the books in the database/booksPOSTJSONAdd a new book in the database/book/{title}GET-Get the book with title=title from the database/book/{title}POSTJSONAdd a new book with title=title in the database/book/{title}PUTJSONUpdate or create the book with title=title in the database/book/{title}DELETE-Delete the book with title=title from the database7.3 AuthorsAPIMethodDataDescription/authorsGET-Get a list of all the authors in the database/authorsPOSTJSONAdd a new author in the database/author/{name}GET-Get the author with name=name from the database/author/{name}POSTJSONAdd a new author with name=name in the database/author/{name}PUTJSONUpdate or create the author with name=name in the database/author/{name}DELETE-Delete the author with name=name from the database