15
15
import logging
16
16
from typing import Dict
17
17
18
- from flask import Flask
18
+ from flask import Flask , request
19
19
from github import Github
20
20
from github .Repository import Repository
21
21
from github_webhook import Webhook
@@ -40,7 +40,7 @@ def __init__(
40
40
self .repo = repo
41
41
self .command_handler = CommandHandler (config , store , repo )
42
42
43
- # Start a flash webserver
43
+ # Start a flask webserver
44
44
self .app = Flask (__name__ )
45
45
46
46
webhook = Webhook (
@@ -49,9 +49,15 @@ def __init__(
49
49
secret = self .config .webhook_secret ,
50
50
)
51
51
52
- @self .app .route ("/" )
53
- def hello_world ():
54
- return "Hello, world!"
52
+ @self .app .route ("/<path:path>" , methods = ["GET" , "POST" ])
53
+ def invalid_path_route (path ):
54
+ """Respond to a request on an unrecognised HTTP method + path combination."""
55
+ # We never expect a GET.
56
+ if request .method != "POST" :
57
+ return "This application only responds to POST requests" , 405
58
+
59
+ # The requester used a POST, but didn't use the configured webhook URL.
60
+ return "Did you forget to use the configured webhook path? :)" , 404
55
61
56
62
@webhook .hook ("issue_comment" )
57
63
def on_issue_comment (data ):
0 commit comments