Host CodeGuard API on Linode (Linux Server)

Host CodeGuard API on Linode (Linux Server)

If you want to use CodeGuard in your project by hosting the API yourself, here is a tutorial!

Installing Python, Pip, And Flask

Run these 3 commands:

apt-get install python3
apt-get install python3-pip
pip3 install flask

Getting the API to your system and setting up NGINX

git clone https://github.com/Omar8345/CodeGuard
apt install nginx
nano /etc/nginx/sites-enabled/api # check nginx_settings in API folder in github
unlink /etc/nginx/sites-enabled/default
nginx -s reload

Install Gunicorn and run the app

apt install gunicorn
cd CodeGuard/API
gunicorn -w <workers> API:app

Be sure that API is all uppercase and also, to know how many workers you have, check how many CPU cores you have and multiply by 2 and add 1.

Video

NOTE

In the __init__.py be sure to actually change the cd commands path to match your path/directory/etc.

If you get that an error of cannot locate python3-pip, execute these 2 commands then retry:

apt-get update
apt-get upgrade

And, if you already installed Flask using pip3 install flask but it shows module not found, try installing pip using apt-get install pip and then pip install flask then retry.

Thank you!