rchavezj / messing-with-python

This repo will contain any references to deploy APIs with Python (FastAPI/Django/Flask) using the following: Vagrant, Docker containers, or AWS (Lambda, Gateway, EC2, Serverless, torchserve via PyTorch).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python DevOps

This repo will contain any references to deploy APIs with Python (FastAPI/Django/Flask) using the following: Vagrant, Docker containers, or AWS (Lambda, Gateway, Serverless, torchserve via PyTorch).

alt text alt text alt text

Contents:

1. Setup Environment Commands 2. Profile API (Django)
3. Hello world (FastAPI) 4. PyTorch Image model (Flask)

Make sure you have the following commands setup on ur API project
(1) Create a configuration file Vagrantfile with server support (ubuntu/bionic64). Somtimes you will need to edit the Vagrantfile in order to setup step (2) properly.

vagrant init ubuntu/bionic64

(2) Download the base image specified inside VagrantFile configuration then start a virtual machine setup with ubuntu server.

vagrant up 

(3) Connect to vagrant server as a 'guest' which is why we use the ssh flag on our command. Ubuntu commands are not the same as windows or mac.

vagrant ssh

alt text
(4) exit --> If you ever wish to exit the development server and back to you're local machine.

(0) Make sure you change directories to the path '/vagrant' inside of the virtua ubuntu.
(1) Development repo is under the folder /vagrant using the command 'cd /vagrant'
(2) Create python environment onto server.

python -m venv ~/env

(3) Activate virtual env

source ~/env/bin/activate

(4) Deactivate virtual environment.

deactivate

Dependency (install inside vagrant env activated)

pip install -r requirements.txt </br>

Django Admin Setip

(1) the script (django-admin.py) is passed in and the argument "startproject" is a flag to start a new project (profiles_project). the "." is an optional argument to place the folder on the root of invoked command.

django-admin.py startproject profiles_project .  

is passed in and the argument "startproject" is
a flag to start a new project (profiles_project).
the "." is an optional argument to place the folder on the root of invoked command.
(2) Start a new django api project using manage.py

python manage.py startapp [name]

(3) Inside of settings.py, repo inside of django api project from step (2), add in the following apps
alt text (4) On the browser type in 'http://127.0.0.1:8000/' to view ur code on the server. Django place holder (img of a rocket) is set to default.

python manage.py runserver 0.0.0.0:8000

(4a) If running the local host ends up in an infinite loop.

python manage.py runserver --noreload 0.0.0.0:8000 

Django Migration setup

These two can create an init file (0001_initial.py)

python manage.py migrate
python manage.py makemigrations [name: profiles_api] 

Django Create superuser

python manage.py createsuperuser 

About

This repo will contain any references to deploy APIs with Python (FastAPI/Django/Flask) using the following: Vagrant, Docker containers, or AWS (Lambda, Gateway, EC2, Serverless, torchserve via PyTorch).


Languages

Language:Python 91.5%Language:Shell 8.5%