Deploying python app with flask on ghost

Hello,

i am running the latest version of ghost.

And

  • configuration was done with the ghost CLI on digital oceans server.
  • as per CLI install

I want to install a simple python application on to link to my below. I want Ghost to go to the api for the app at open-ivf.com/api/v1/predictor but i am unsure of how i need to configure my nginx setup or if it at all possible after i have used the ghost CLI install.

cheers


import flask
import numpy as np
import pickle
from flask import request

app = flask.Flask(name)
app.config[“DEBUG”] = False

@app.route(’/api/v1/predictor’, methods=[‘GET’])
def home():
if ‘age’ in request.args:
age = int(request.args[‘age’])
else:
return “Error: No age field provided. Please specify.”

if 'n_eggs' in request.args:
    n_eggs = int(request.args['n_eggs'])
else:
    return "Error: number of eggs not provided. Please specify."

if 'rank' in request.args:
    rank = int(request.args['rank'])
else:
    return "Error: number of attempts at ivf not provided. Please specify."

pat = np.asarray([[age,n_eggs,rank]])
filename='RFC1opt.sav'
loadRFC1=pickle.load(open(filename,'rb'))
prediction = loadRFC1.predict_proba(pat)[0][1]




return f'<h1>Open IVF fert predictor</h1><p>At age {age} and with {n_eggs} eggs collected on your {rank} attemt you have {prediction} chance.</p>'

if name == ‘main’:
app.run()