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
- Host: GitHub
- URL: https://github.com/dsdatsme/flask-setup-for-instance
- Owner: DSdatsme
- Created: 2018-12-18T11:51:26.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-10-13T01:53:50.000Z (about 4 years ago)
- Last Synced: 2025-02-12T12:55:20.971Z (10 months ago)
- Topics: flask, hacktoberfest
- Language: JavaScript
- Homepage:
- Size: 241 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.