I made a demo, but there are two questions:
1. Whether the HTTP request method is GET or POST, all I get is GET, why?
2. Why is the status code of the http response 301
demo
import cherrypy
class Hello:
@cherrypy.expose
def index(self):
print(cherrypy.request.method)
return 'hello'
class App:
def __init__(self):
self.hello = Hello()
@cherrypy.expose
def index(self):
return 'index'
cherrypy.quickstart(App(), '/api')
log
127.0.0.1 - - [09/Aug/2023:14:51:06] "GET /api/hello HTTP/1.1" 301 119 "" "PostmanRuntime/7.32.3"
GET
127.0.0.1 - - [09/Aug/2023:14:51:07] "GET /api/hello/ HTTP/1.1" 200 5 "
http://127.0.0.1:9999/api/hello" "PostmanRuntime/7.32.3"
127.0.0.1 - - [09/Aug/2023:14:51:14] "POST /api/hello HTTP/1.1" 301 119 "" "PostmanRuntime/7.32.3"
GET
127.0.0.1 - - [09/Aug/2023:14:51:14] "GET /api/hello/ HTTP/1.1" 200 5 "
http://127.0.0.1:9999/api/hello" "PostmanRuntime/7.32.3"