Skip to content

Simple API that receives the HTML Base 64 String for an image and returns a URL for that image in the server

Notifications You must be signed in to change notification settings

josewebdev2000/Py-Pic-Box

Repository files navigation

Py Pic Box

Py Pic Icon

Overview

This project is my personal Web API to upload images to an online web server.

Why is this required?

Imagine you are working on a programming project that requires you to share images.

How will you share those images to people that use other computers?

Where will you host those images and access them through code?

Well, I have answered those questions for myself by building this project.

  1. I will share images to people of other computer by uploading those images online and sharing the url of the image
  2. I will host them in my own web server that has a web service that gives me back the url for the images I uploaded

Mechanism

My Web API has three routes:

  • /upload: Route used to upload images to the server (POST Request Only)
  • /delete: Route used to delete images to the server (POST Request Only)
  • /pics: Route used to show images stored in the web server (GET Request Only)

My Web API takes a JSON string with the following fields for the /upload route:

  • key: API KEY required to use the API
  • imgbase64: Base 64 Code that contains the data that describes the image
  • name: Name the user wants for this image to have

The imgbase64 field expects the HTML Base 64 encoded version for image data that follows the following format:

data:[mediatype];base64,

Example:

data:image/png;base64,{base64 pure code starts from here on}

A successful response for the /upload route will contain this following JSON field:

  • img_url: URL to the image the user just uploaded through Base 64 Code

My Web API takes a JSON string with the following fields for the /delete route:

  • key: API KEY required to used the API
  • imgurl: URL for the image hosted in the web server that is to be deleted

A successful response for the /delete route will contain this following JSON field:

  • message: A confirmation that contains the old URL of the deleted image which leads to a 404 response

An erroneous response for either the /upload route the /delete route will contain the following JSON field:

  • error: Description of the error raised

To trigger a successful response from the /pics route:

  1. Trigger a GET request to https://py-pic-box.vercel.app/pics/{image-filename}
  2. Receive the image

Skills

The following technologies were required to compelte this project

  • Python
  • Flask

Copyright

About

Simple API that receives the HTML Base 64 String for an image and returns a URL for that image in the server

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages