Project Name: Zadia Video App(https://zadiavideo.oskarcode.com/)

Update Project Delete Project

Project description

-User upload videos from local with uploading page where you can enter name, description, video, uploaded time
-I use Cloudflare stream upload API( https://developers.cloudflare.com/stream/uploading-videos/upload-video-file/) to upload video from local. For this, we need to create an api endpoint, headers( with authentication),and files( open and read file from local), and send a POST request to the api endpoint. We retrieve the video UID, watchable URL from the response. Once we upload, we display the video with their watchale URL and delete them with UID.

Project steps

Add Steps

Step1:Models.py

Update step Delete step

Step description:

 we define, name, description, uploaded time( auto_now) and video fields
Make sure to have default and null value, otherwise you might have issues when running migrate command 
1

Step2:Views.py

Update step Delete step

Step description:

-A function which takes filepath as a parameter to retrieve video watch url, video uid. We call the upload API and get the correspondent data from the response. We use requests.POST method to send requests to the api endpoint.
 -Upload_function. We take data such as name, description  from request.FILE() and request.POT. Once we retrieve the video,we need to store them in tmp file as we need a filepath to call the API. With file path, we call the API and save the response into data base.
-We have delete function to delete the specific video both from database and cloudflare stream 

Step3:Git push to remote repo

Update step Delete step

Step description:

Git upload to the remote depository

Step4:Git pull

Update step Delete step

Step description:

clone to the server( aws ec2)

Step5:Create venv( python -m venv 'venv'

Update step Delete step

Step description:

Create a  virtual environment in ec2 and install all packages from requirement.txt file

Step6:Production env static files

Update step Delete step

Step description:

Collect static files to the /static path

Step7:Files paths

Update step Delete step

Step description:

Check out the location for django application( used for gunicorn.service), venv, and wsgi file 

Step8:Pip3 in venv

Update step Delete step

Step description:

Make sure pip3 is installed within venv otherwise the downloaded packages do not work in the environment.

Step9:Socket file

Update step Delete step

Step description:

Create socket file.cd /etc/systemd/system/

Step10:Create .service file

Update step Delete step

Step description:

Create .service file( make sure the path for app,venv, wsgi are correct)./etc/systemd/system/
- Enable the socket and test the status of socket and services with sudo systemctl status 

Step11:Creare nginx config file

Update step Delete step

Step description:

-make sure to include the ssl certificate location)
- make it available with, sudo ln -s /etc/nginx/sites-available/cypher /etc/nginx/sites-enabled/

Step12:Restart all files

Update step Delete step

Step description:

-sudo systemctl restart video.socket video.service

Step13:Cloudflare set up

Update step Delete step

Step description:

add  cname in cloudflare( cname to ec2 public DNS name)

    Issues and solutions

    Add Issue
  • Issue 1-only accept http request, no https request:- The site is only available with http not https
    Update Issue Delete Issue Add Solution
    • Solution 1-Add SSL Certificate to the nginx server config:https://www.digitalocean.com/community/tutorials/how-to-host-a-website-using-cloudflare-and-nginx-on-ubuntu-20-04
      Update solution Delete solution