Browse Source

Update 'README.md'

天问 1 month ago
parent
commit
61ba8d265d
1 changed files with 15 additions and 4 deletions
  1. 15 4
      README.md

+ 15 - 4
README.md

@@ -6,7 +6,7 @@
 ## Usage
 
 ```
-from flask import Flask
+from flask import Flask, request
 from flask_restful import Resource, Api
 
 app = Flask(__name__)
@@ -17,11 +17,22 @@ class HelloWorld(Resource):
     
     # 覆写get,post等方法处理 HTTP 请求
     def get(self):
-        return {'hello': 'world'}
-
-api.add_resource(HelloWorld, '/')
+        data = request.json
+        return {'hello': 'world'+ data.get("id") }
+    
+    def post(self):
+        data = request.json
+        return {'hello': 'world'+ data.get("id") }
+    
+    def delete(self):
+        data = request.json
+        return {'hello': 'world'+ data.get("id") }
+        
+api.add_resource(HelloWorld, '/hello')
 
 if __name__ == '__main__':
     app.run(debug=True)
 
 ```
+然后访问:http://localhost/hello?id=11
+