Hey guys,

I'm trying to add a webhook to a project but it doesn't work. it always gives an Internal server error. I tried it locally but that worked. Also I tried just returning the request.json and manually changing the values to a dataframe. The site is connected to the web and it receives the json file.

The error is(flask): AttributeError: 'dict' object has no attribute 'to_html'

code from QC:

data = {
            'symbol':self.aapl.Symbol.Value,
            'time':self.Time,
            'order Filled': random.randint(1000, 1001),
            'order Sold': random.randint(1003, 1007),
            'quantity': 1,
            'profit': random.randint(1003, 1007)
        }
        
        if self.orders_dataframe is None:
            self.orders_dataframe = pd.DataFrame(data=data,index=[0])
        else:
            self.orders_dataframe = self.orders_dataframe.append(data, ignore_index=True)
json_df = self.orders_dataframe.to_json(date_unit='ns')

self.Notify.Web('https://startfrom0sen.pythonanywhere.com/webhook', json_df)

code on PythonAnywhere:

from flask import Flask, request, Response, render_template, abort
import pandas as pd
from threading import Thread
import json

df = None
app = Flask(__name__,template_folder='templates')
counter = 0
ds = None


@app.route("/webhook", methods=["POST"])
def webhook():
    global df
    if request.method == 'POST':
        counter=+ 1
        print(request.json)
        if df is None:
            df = request.json
            df = pd.read_json(df)
            ds = df
            df = df.iloc[:, [4,5,3,2,0,1]]
            df['time'] = pd.to_datetime(df['time'])

        else:
            js_df = request.json
            js_df = pd.read_json(js_df)
            js_df = js_df.iloc[:, [4,5,3,2,0,1]]
            js_df['time'] = pd.to_datetime(js_df['time'])
            df = df.append(js_df)
        return df





        return "success", 200
    else:
        abort(400)
        

@app.route("/")
def main():
    if df is None:
        return str(counter)
    else:
        return str(counter), df.to_html()



if __name__ == '__main__':
    app.run()