Trivial API server
parent
35edfa3f63
commit
df01455aab
|
@ -0,0 +1,31 @@
|
||||||
|
from flask import Flask, jsonify
|
||||||
|
|
||||||
|
# Create an instance of the Flask class
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
# Define a route for the root URL
|
||||||
|
@app.route('/')
|
||||||
|
def home():
|
||||||
|
return jsonify({
|
||||||
|
"message": "Welcome to my simple web service!"
|
||||||
|
})
|
||||||
|
|
||||||
|
# Define another route for /hello/<name>
|
||||||
|
@app.route('/hello/<name>')
|
||||||
|
def hello_name(name):
|
||||||
|
return jsonify({
|
||||||
|
"message": f"Hello, {name}!"
|
||||||
|
})
|
||||||
|
|
||||||
|
# Define a route for health check
|
||||||
|
@app.route('/health')
|
||||||
|
def health_check():
|
||||||
|
return jsonify({
|
||||||
|
"status": "OK"
|
||||||
|
})
|
||||||
|
|
||||||
|
# Run the Flask app
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(debug=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue