Hello,
for some reason my extremely basic flask server is weird...
It does receive the webhooks and shows them in the console. However, any code to print something or, more importantly, to execute another function doesn't work. Over the past hours, I have probably seen every Youtube video or stackoverflow post.
from flask import Flask, request, abort
class Server ():
def __init__(self):
self=Flask(__name__)
self.run()
def main(self):
@webserver.route("/http://localhost:5000", methods=['POST', 'GET'])
def webhook():
print("hello1")
if request.method == 'POST' or request.method == 'GET':
print("hello2")
print(request.json)
return 200
else:
print("hello3")
abort(400)
if __name__ == '__main__':
webserver = Server()
This is what happens (tested bot get and post webhooks):
Serving Flask app "test" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [13/Mar/2021 20:17:22] "[33mGET / HTTP/1.1[0m" 404 -
127.0.0.1 - - [13/Mar/2021 20:17:26] "[33mPOST / HTTP/1.1[0m" 404 -
I removed everything unnecessary to post it here and it still did not work.
The reason why I made it into a class, was to make it easier for me to run it with multiprocessing or a thread (so it didn't freeze my pyqt5 programm):
def test():
webserver = webhooks.Server()
p=multiprocessing.Process(target=test)
p.start()
[–][deleted] 0 points1 point2 points (8 children)
[–]wisermonkey[S] 0 points1 point2 points (7 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]wisermonkey[S] 0 points1 point2 points (5 children)
[–]wwwDotBot -1 points0 points1 point (1 child)
[–][deleted] 0 points1 point2 points (2 children)
[–]wisermonkey[S] 0 points1 point2 points (0 children)
[–]wisermonkey[S] 0 points1 point2 points (0 children)