How about using Flask? Below is an example of using Flask.
#app.py
from flask import Flask, request
import machine #machinelearningpy
app = Flask(__name__)
@app.route("/")
def main():
html = '<form action="http://127.0.0.1:8000/submit" name="machine" method="post">\
<input type="text" name="input">\
<input type="submit" value="submit"> </form>'
return html
@app.route("/submit" , methods=['POST'])
def answer():
if request.method == 'POST':
data = request.form['input']
result = machine.input(data)
return result
if __name__ == '__main__':
app.run(host="0.0.0.0", port=8000, debug=True)
#machine.py
def input(x):
result = 'hi '+ x
return result
© 2024 OneMinuteCode. All rights reserved.