# Flask Backend

The backend code is written in Python 3 and uses Flask to serve the API

The purpose of the backend code is to:

* Communicate with the OpenAI Beta API
* Pass on the responses to the chrome extension

## Pre-Requisites

* GPT-3 Beta access (This gives you an API key that you would need to pass on with the API requests to OpenA
* Python 3
* Flask

## File Structure

<div align="left"><img src="https://538899350-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MD-IJzz9MPZsGBtxKYM%2F-MD-IP0MPgzaYzHYLR39%2F-MD-bFHGOfRREA8EUrlE%2Fimage.png?alt=media&#x26;token=0eb25687-10ff-4c98-b2d2-76b01836ae1d" alt=""></div>

* backend.py : Backend code in Python (Flask)
* credentials.py : File contain API key. This file isn't part of the repo. You will have to create one and add the API key that you receive from openai

<div align="left"><img src="https://538899350-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MD-IJzz9MPZsGBtxKYM%2F-MD-IP0MPgzaYzHYLR39%2F-MD-bfCADSu_lEfyRDh7%2Fimage.png?alt=media&#x26;token=166253bc-01c4-4437-b80b-9abbfd49c2ee" alt=""></div>

## Installation

### Install dependencies

```
$ pip install openai
$ pip install pandas
```

### Starting Script

{% code title="cd project-folder" %}
```bash
$ export FLASK_APP=backend.py
$ flask run
```
{% endcode %}

This is a sample output of the flask server running waiting to serve API requests. I'm running it locally.

![](https://538899350-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MD-IJzz9MPZsGBtxKYM%2F-MD-IP0MPgzaYzHYLR39%2F-MD-MAnNE3G5qutg7fUs%2Fimage.png?alt=media\&token=93db7e6e-0d07-47e8-ba1d-a4635a1036bf)

The backend is now ready. Let's move on to the Chrome Extension
