mirror of
https://github.com/opelly27/PythonAPI.git
synced 2026-05-20 00:38:47 +00:00
initial commit
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
from flask import Flask
|
||||||
|
from flask_restful import Api, Resource
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
api = Api(app)
|
||||||
|
|
||||||
|
class HelloWorld(Resource):
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
return {"data": "hello world"}
|
||||||
|
|
||||||
|
api.add_resource(HelloWorld, "/helloworld")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run(debug=True)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
base = "http://127.0.0.1:5000/"
|
||||||
|
|
||||||
|
r = requests.get(base + "helloworld")
|
||||||
|
|
||||||
|
print(r.json())
|
||||||
Reference in New Issue
Block a user