Source code for Profile REST API

Overview

PROJECT PROFILE REST API

Creating local development server:

We will create a local development server that can run and test our API as we build it. We are going to be creating a development server using a tool called Vagrant. Vagrant allows you to define the type of server you need for the project as a vagrant file and store this file with the source code of our project. You can create a new vagrant file by using the vagrant CLI tool.

vagrant init ubuntu/bionic64

It initializes our project with a new vagrant file and it bases it on the ubuntu bionic 64 base image. These images are publicly available in the vagrant catalog box.

vagrant up

what this will do is it will download the base image that we've specified in our vagrant file and then it will use VirtualBox to create a new virtual machine and then run our provisioning script when it starts the machine.

vagrant ssh

once the vagrant box has been started we can then connect to the vagrant server by using the vagrant SSH command. Since our box is a completely different isolated box on our machine so it's a guest operating system, we need to connect to it using SSH.

exit

To disconnect from the machine simply type exit and this will take you outside of the machine back onto your local machine.

when you connect to the machine and any command that you run in the terminal while you're connected to the machine will be ran on the guest operating system or the development server instead of your local machine.

Synchronizing the development server with project directory:

For Synchronizing the development server with project directory you need to first connect to vagrant server. Once you connect to vagrant server type:

cd /Vagrant

This will switch you to vagrant directory on our server. Now everything in this vagrant directory is synchronized with everything in our project folder. This synchronization works both ways from the server to our host and form our host to the server.

Python virtual enviroment:

To create a python virtual environment go to the vagrant directory and use python venv command:

python -m venv ~/env

using ~ will create python virtual environment in the home directory of the your vagrant server (which is not synchronized with local machine) opposed to the vagrant folder which is synchronized with our local machine. The way virtual environment works you need to activate and deactivate them. So when you're activated on a virtual environment all of the dependencies that you run in the python application will be pulled from the virtual environment instead of the base operating system. To activate virtual environment:

source ~/env/bin/activate

To switch off from virtual environment type:

deactivate

Installing required packages:

To install the required packages which is django and djangorestframework for our project first create requirements.txt file and then edit the file as follow: django== djangorestframework== save the file.

touch requirements.txt

To install the requirements make sure that you are in vagrant directory and virtual environment is activated. Now type:

pip install -r requirements.txt

-r stands for requirements.

Creating Django project and application:

To create a django project we will use django command line tool - django-admin.

django-admin.py startproject profiles_project .

To create a django application

python manage.py startapp profiles_api

Enabling the application:

You need to go to settings file for your django project and find "INSTALLED_APPS" block, this is where we need to list all of the apps that you need to use for your project. These are the following apps you need to add:

'rest_framework',
'rest_framework.authtoken',
'porfiles_api',

Start Django development web server for testing:

You can start the django development server, first make sure you are using vagrant box and inside the vagrant directory and virtual enviroment is turned on. Now use:

python manage.py runserver 0.0.0.0:8000

"python manage.py" It asks the django to start running development web server and this "0.0.0.0" means make it available on all network adapters on our development server and this ":8000" says start it in port 8000 so we can access it via port 8000. Now go to browser and type in search bar 127.0.0.1:8000 to check the that the server is up and running.

You might also like...
Google scholar share - Simple python script to pull Google Scholar data from an author's profile

google_scholar_share Simple python script to pull Google Scholar data from an au

A Telegram bot to download posts, videos, reels, IGTV and a user profile picture from Instagram!
A Telegram bot to download posts, videos, reels, IGTV and a user profile picture from Instagram!

Telegram Bot A telegram bot to download media from Instagram! No API Key or Login Needed! Requirements You must have python installed (of course) You

A Python Library to interface with Flickr REST API, OAuth & JSON Responses

Python-Flickr Python-Flickr is A Python library to interface with Flickr REST API & OAuth Features Photo Uploading Retrieve user information Common Fl

A Python Library to interface with Tumblr v2 REST API & OAuth

Tumblpy Tumblpy is a Python library to help interface with Tumblr v2 REST API & OAuth Features Retrieve user information and blog information Common T

Python library for interacting with the Wunderlist 2 REST API

Overview Wunderpy2 is a thin Python library for accessing the official Wunderlist 2 API. What does a thin library mean here? Only the bare minimum of

A very simple Salesforce.com REST API client for Python

Simple Salesforce Simple Salesforce is a basic Salesforce.com REST API client built for Python 3.5, 3.6, 3.7 and 3.8. The goal is to provide a very lo

HTTP Calls to Amazon Web Services Rest API for IoT Core Shadow Actions 💻🌐💡

aws-iot-shadow-rest-api HTTP Calls to Amazon Web Services Rest API for IoT Core Shadow Actions 💻 🌐 💡 This simple script implements the following aw

📦 Opensource Python wrapper for Hiven's REST and WebSocket API
📦 Opensource Python wrapper for Hiven's REST and WebSocket API

hiven.py 📦 Opensource Python wrapper for Hiven's REST and WebSocket API Installation pip install -U hiven.py Usage hiven.py is currently under devel

Jackrabbit Relay is an API endpoint for stock, forex and cryptocurrency exchanges that accept REST webhooks.

JackrabbitRelay Jackrabbit Relay is an API endpoint for stock, forex and cryptocurrency exchanges that accept REST webhooks. Disclaimer Please note RA

Owner
null
Status-embed - Cool open source profile embed for Discord

Current Status : Incomplete Status Embed Status Embed is an awesome open source

Ritabrata Das 2 Feb 17, 2022
Demo to explain how to use AWS Chalice to connect to twitter API and change profile picture at scheduled times.

chalice-twitter-demo Demo to explain how to use AWS Chalice to connect to twitter API and change profile picture at scheduled times. Video Demo Click

Ahmed Mohamed 4 Dec 13, 2021
Tracks how much money a profile has in their bank and graphs it, as long as they enable the bank api

Tracks how much money a profile has in their bank and graphs it, as long as they enable the bank api. (you could really use this to track anything from the hypixel api)

null 1 Feb 8, 2022
OSINT tool to get information from a Github and Gitlab profile and find user's email addresses leaked on commits.

gitrecon OSINT tool to get information from a Github or Gitlab profile and find user's email addresses leaked on commits. ?? How does this work? GitHu

GOΠZO 211 Dec 17, 2022
Changes the Telegram bio, profile picture, first and last name to the song that the user is currently listening to.

TGBIOFY - Telegram & Spotify integration Changes the Telegram bio, profile picture, first and last name to the song that the user is currently listeni

elpideus 26 Dec 7, 2022
An hcaptcha-solving discord account generator; capable of randomizing names, profile pictures, and verifying phone numbers.

discord-account-generator An hcaptcha-solving discord account generator; capable of randomizing names, profile pictures, and verifying phone numbers.

Acier 61 Dec 10, 2022
Powerful Telegram userbot to turn your PROFILE PICTURE & LAST NAME into a real time clock & to change your BIO automatically.

DATE_TIME_USERBOT-TeLeTiPs Powerful Telegram userbot to turn your PROFILE PICTURE & LAST NAME into a real time clock & to change your BIO automaticall

null 53 Jan 5, 2023
Follow pixiv account from twitter profile

Follow pixiv account from twitter profile

Genshi 7 Apr 11, 2022
A simple tool that allows you to change your default AWS CLI profile.

Select AWS Profile Select AWS Profile (slapr) is a simple tool that lets you select which AWS Profile you want to use and sets it as the default AWS p

Antoni Yanev 2 Nov 9, 2022
A powerful, cool and well-made userbot for your Telegram profile with promising extension capabilities.

Telecharm userbot A powerful, fast and simple Telegram userbot written in Python 3 and based on Pyrogram 1.X. Currently in active WIP state, so feel f

Daniil Kovalenko 16 Dec 1, 2022