-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5bf1d5c
Showing
7 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Publish to NPM | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
registry-url: https://registry.npmjs.org/ | ||
|
||
- name: Publish package on NPM | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Insomnia Python Script | ||
|
||
Run any complex logic with python and get the result with Insomnia. | ||
|
||
## Prerequisites | ||
|
||
- Have `python3` configured at your `$PATH` | ||
|
||
## Install | ||
|
||
1. Open Insomnia | ||
2. Go to Application > Preferences > Plugins | ||
3. Type `insomnia-plugin-python-script` | ||
4. Install the plugin | ||
|
||
## Usage | ||
|
||
### Write your complex python script | ||
|
||
Your script must return de desired result by printing it. | ||
|
||
At `~/path/to/file.py`: | ||
``` | ||
def complex_logic(): | ||
return ("complex_result") | ||
print(complex_logic()) | ||
``` | ||
|
||
### Add the plugin to desired field | ||
|
||
Type `CTRL + SPACE` then search for Python Script, and select the plugin | ||
|
||
![Screenshot](https://raw.githubusercontent.com/wuerike/insomnia-plugin-python-script/main/npm/content/example1.png) | ||
|
||
|
||
### Set the path of your python script | ||
|
||
You'd better use a global path starting with `~/` to avoid any problem | ||
|
||
![Screenshot](https://raw.githubusercontent.com/wuerike/insomnia-plugin-python-script/main/npm/content/example2.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const execSync = require("child_process").execSync; | ||
|
||
module.exports.templateTags = [ | ||
{ | ||
name: "pyScript", | ||
displayName: "Python Script", | ||
description: "Run python3 script.", | ||
args: [ | ||
{ | ||
displayName: "File path", | ||
placeholder: '~/file.py', | ||
type: "string", | ||
}, | ||
], | ||
async run(context, path) { | ||
try { | ||
var resp = execSync( `python3 ${path}`, { encoding: "utf-8" }); | ||
} catch (failed) { | ||
console.log("Command execution failed with " + failed); | ||
return failed.stderr; | ||
} | ||
|
||
return resp.trim(); | ||
}, | ||
}, | ||
]; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "insomnia-plugin-python-script", | ||
"version": "0.1.0", | ||
"insomnia": { | ||
"name": "python-script", | ||
"displayName": "Python Script", | ||
"description": "Run python3 script.", | ||
"images": { | ||
"icon": "npm/content/logo.png" | ||
} | ||
}, | ||
"keywords": [ | ||
"insomnia", | ||
"plugin", | ||
"python", | ||
"script" | ||
], | ||
"main": "main.js" | ||
} |