jeudi 7 mai 2020

Accessing Python functions with Ajax

I’m new to python and web related code so excuse the probably dumb question. I was wondering if it’s possible for me to write some functions in python, and then for them to be used on a website.

Specifically, I have coded a few simple functions that take a users input (string of a musical chord like “Amin7sus2”) and return the notes that make up that chord (A, B, E, G). Now the goal is to have a web app where someone can type the chord, and then it accesses the python functions to return the notes.

I have a friend who does front end, and he mentioned Ajax to me for accessing python through jquery, but I can’t find any examples of it doing something quite like this.

It takes around 10 smaller functions to achieve the conversion from string to a list of notes, as well as accessing several dictionaries within python. I’m essentially looking for a way to feed the input from the web (a simple string) through my series of functions in python to finally return the list of notes.

Below is a very symbolic version of my python code that I wish to feed user input from the web into:

def dict1():
    #dict1
    return dict1

def func1(input):
    #input_to_chord_quality
    return input_to_chord_quality

def func2(input_to_chord_quality):
    #access dict1
    #quality_to_notes
    return quality_to_notes

def main():
    return func2(func1(input))

Can anyone offer some guidance on how to use python logic for a web app feature?




Aucun commentaire:

Enregistrer un commentaire