How to Deploy Python Web Socket & Rest API on AWS EC2 Server
1. About Python
Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured, object-oriented and functional programming. Also python code is build run time so no need to be build.
2. Prerequisite
Login AWS Account
Launch EC2 Instance with Ubuntu OS and Open port 8000 globally to access API
3. Install Python3 or latest python version on Server
sudo su
apt-get update
sudo apt install python3 or sudo apt install python3.8
python --version
4. Install PIP3 or latest version
sudo apt-get update
sudo apt-get -y install python3-pip
pip3 --version
5. Then clone your code from github or any code repository into a new folder
mkdir "Folder name"
cd "Folder name"
git clone "repo-name"
6. After clone the code we create a python virtual environment
pip3 install virtualenv
virtualenv mypython (mypython is env name you give according to your need)
#or
virtualenv venv --python=python3.9 (venv is name)
7. Start Virtual environment or Active
source mypython/bin/activate
#or
source venv/bin/activate
8. then install requirements file in your python code in that code its mention dependencies
pip install -r requirements.txt
9. then run your server or deploy API(open port publicly i.e. 8000)
python3 ./manage.py runserver 0.0.0.0:8000
if any error come like djano not install then install djano
10. After that you run again API its deploy successfully & hit your public IP with port number