A custom uploader for ShareX images and files for your server written in Python with Flask. Currently in beta, there may be some issues. If you do find any please raise a GH issue to let me know
These steps are for NGINX users. Apache users can find links to their own steps at the footer. Users running this off of serverless solutions like Heroku should consult their service's documentation for how to deploy.
- Run
sudo apt update
then Install the required Python packages with:sudp apt install python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools
(how you acquire them depends on your distribution) - Run
sudo apt install python3-venv
. - Visit your directory of choice where you wish the project to be located on your server and run
git clone https://github.com/dev-sda1/ShareX-Uploader.git
- CD into the directory with
cd ShareX-Uploader
- Open
server/config.json
in your text editor of choice. This is where your client secret will be stored. - Make sure your client secret is long and stored safely. A password generator site like this one, or the generator tool in your password manager software can be used to create a long key.
- Save the config file and cd back to the projects root directory
- Run
python3 -m venv sharexupload-env
, thensource sharexupload-env/bin/activate
. Your prompt should change to something along the lines of(sharexupload-env)user@host
. - Now it's time to install the pip packages that make the server work - run
pip3 install -r pip.txt
to install them. - Test that uwsgi installed properly by running
uwsgi --socket 0.0.0.0:5000 --protocol=http -w wsgi:app
and checking in your browser that a 404 message returns withhttp://your_server_ip:5000
. You can change the 5000 port to anything else, if you want to. - Exit the env by running
deactivate
, and enterShareXUploader.service
in the text editor of your choice. - Change
ADD_USER_HERE
and all instances ofUSER_HERE
to your username. - Change all instances of
ADD_DIRECTORY_HERE
to where you cloned the repository. (e.g/home/pyxlwuff/ShareX-Uploader/
) - Change all instances of
ENV_FOLDER
tosharexupload-env
- Copy the resulting .service file to
/etc/systemd/system/
- Run
sudo systemctl start ShareXUploader
and thensudo systemctl enable ShareXUploader
- Check the status to ensure there's no errors by running
sudo systemctl status ShareXUploader
. If there are any errors, ensure to correct them before continuing and restarting the service withsudo systemctl restart ShareXUploader.service
- Now that we know our server is up and running, we can now configure our NGINX endpoint. Create a new file with
sudo nano /etc/nginx/sites-available/sharex-uploader
- Copy the following block below, replacing
your_domain
with the domain of your choice, and DIRECTORY_HERE with where you stored the repository:
listen 80;
server_name your_domain www.your_domain;
location / {
include uwsgi_params;
uwsgi_pass unix:DIRECTORY_HERE/ShareXUploader/app.sock;
}
}
- Run
sudo ln -s /etc/nginx/sites-available/sharex-uploader /etc/nginx/sites-enabled
to link it to the sites-enabled directory, making it resolvable, followed bysudo nginx -t
to test the configuration is OK. If you get any errors, make sure to resolve them first. - Restart nginx with
sudo systemctl restart nginx
, then navigate to your domain to see if it worked! (You should see a file not found error - this is normal)
- Download the example template here
- Double click it and select "yes" on the prompt that shows up
- Your custom upload defaults should now change to the template you just imported. Begin by editing the Request URL to your domain.
- Add the secret you added to your server's config.json earlier into the form value.
- Scroll down to the URL section and change
yourdomain.here
to your domain.
- Click the "Test" button next to Image uploader and see if you get a response. If you get something similar to the screenshot below, you're good to go! Otherwise, you might need to check your secret or URL settings. If it's not that, it might be something on the server.
If you use another solution like Apache, you can find instructions tailored to your server here: https://www.codementor.io/@abhishake/minimal-apache-configuration-for-deploying-a-flask-app-ubuntu-18-04-phu50a7ft
Note that as said earlier if you use a serverless service like Heroku to host this, you will need to consult your service's documentation for the best way to deploy without issues.