An open API service indexing awesome lists of open source software.

https://github.com/dsdatsme/flask-setup-for-instance

In this repo I am setting up flask server on cloud compute and then will execute a predefined task from a cloud function, in short will do some task inside instance from external trigger
https://github.com/dsdatsme/flask-setup-for-instance

flask hacktoberfest

Last synced: 9 months ago
JSON representation

In this repo I am setting up flask server on cloud compute and then will execute a predefined task from a cloud function, in short will do some task inside instance from external trigger

Awesome Lists containing this project

README

          

# Flask Execute on Instance

Repo contains a sample code to be used to create a webservice and which in turn will do some kind of execution on host machine.

## Steps to Setup

we will be using python3

```bash
sudo apt-get update
sudo apt-get install git -y
sudo apt-get install python-pip -y
sudo pip install Flask
export FLASK_APP=run.py
pip install flask_cors
```

### to run use following command

```bash
flask run
```

### To kill flask server on a port

```bash
sudo apt-get install psmisc
run sudo fuser -k 5000/tcp
```

## Flow

* Clone the code on virtual machine of your desired cloud provider.
* Make changes in [api/run.py](api/run.py) file. The changes you want to make are in '@app.route' 's parameter.
Give it a desired name of you choice. This will be used while sending request to that webservice.
Example: /my_app_route
* Next thing you want to change is the code inside the method. Write your own logic what you want to do inside the method below the line where you edited your '@app.route'.
* That's it! Now run the flask app considering you have followed all the setup steps.

> You can ignore the `ui` folder, it's just some starter code.

## TLDR

Trigger a webservice hosted in flask from a cloud function or lambda.