[Vuejs]-Best way to interact between vue.js and a python script

0👍

The best idea I can think of is to set up HTTP endpoints in your Flask API and from there call the API directly from your Vue application.

Something like this:
Python script

from flask import Flask, request
app = Flask(__name__)

@app.route("/", methods=["GET", "POST"])
def index():
    if request.method == "GET":
        return "You data here"
    else:
        body = request.body #access the body you sent on JS below
        <put whatever you want to do here>

Javascript

const myRequest = async() =>{
    const response = fetch("http://localhost:8000", {
        method: "POST",
        headers:{
            "Content-Type": "Application/JSON"}
        body:{<your stuff here>}
        )
}

Leave a comment