changed restart_this_app to display html with data from json
This commit is contained in:
parent
f11ee9f51b
commit
5f47adf1e8
2
app.py
2
app.py
@ -12,7 +12,7 @@ def webhook():
|
||||
subprocess.run(['git', 'pull'])
|
||||
|
||||
# Restart the example_app
|
||||
subprocess.run(['systemctl', 'stop', 'restart_this_app.service'])
|
||||
subprocess.run(['systemctl', 'restart', 'restart_this_app.service'])
|
||||
|
||||
return 'Success!', 200
|
||||
else:
|
||||
|
@ -1,14 +1,14 @@
|
||||
from flask import Flask, request
|
||||
import json
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/restart-this-app')
|
||||
def funky_function():
|
||||
data = { 'message': "Joe mama" }
|
||||
response = json.dumps(data)
|
||||
|
||||
return response, 200, { 'Content-Type': 'application/json' }
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5002)
|
||||
from flask import Flask, render_template
|
||||
import json
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/restart-this-app')
|
||||
def render_message():
|
||||
with open('data.json', encoding='UTF-8') as file:
|
||||
data = json.load(file)
|
||||
|
||||
return render_template('index.html', data=data)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5002)
|
17
templates/index.html
Normal file
17
templates/index.html
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Recipe</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>{{ data.text }}</h1>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user