Browse Source

use the same code for online and offline

ca-cert-and-multi-ks
Nicolas Massé 2 years ago
parent
commit
373cc04670
  1. 24
      application/Dockerfile
  2. 4
      application/README.md
  3. 20
      application/src/app.py
  4. 36
      application/src/local/index.html
  5. 36
      application/src/online/index.html
  6. 18
      application/src/static/style.css
  7. 29
      application/src/templates/index.html

24
application/Dockerfile

@ -1,21 +1,5 @@
# Use an official Python runtime as a parent image # Use the Nginx unprivileged as a parent image
FROM python:3.8-slim FROM docker.io/nginxinc/nginx-unprivileged:1.25-alpine
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY src /app
# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org Flask
# Make port 80 available to the world outside this container
EXPOSE 5000
# Define environment variable
ENV NAME World
# Run app.py when the container launches
CMD ["python", "app.py"]
# Copy the static content into the container at /usr/share/nginx/html/
COPY src/local/index.html /usr/share/nginx/html/

4
application/README.md

@ -9,13 +9,13 @@ podman build -t localhost/kiosk-app:latest .
Run the container image. Run the container image.
```sh ```sh
podman run -it --rm --name kiosk-app -p 5000:5000 localhost/kiosk-app:latest podman run -it --rm --name kiosk-app -p 8080:8080 localhost/kiosk-app:latest
``` ```
Test it. Test it.
```sh ```sh
curl -I http://localhost:5000/ curl -I http://localhost:8080/
``` ```
Login to the registry. Login to the registry.

20
application/src/app.py

@ -1,20 +0,0 @@
import platform
from flask import Flask, render_template
app = Flask(__name__, template_folder="/app/templates")
@app.route('/')
def system_info():
system_info = {
'System': platform.system(),
'Node Name': platform.node(),
'Release': platform.release(),
'Version': platform.version(),
'Machine': platform.machine(),
'Processor': platform.processor()
}
return render_template('index.html', system_info=system_info)
if __name__ == '__main__':
app.run(host="0.0.0.0", debug=True)

36
application/src/local/index.html

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="refresh" content="5">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f2f2f2;
}
header {
background-color: #333;
color: white;
padding: 1em;
text-align: center;
}
main {
margin: 2em;
}
</style>
<title>Kiosk application</title>
</head>
<body>
<header>
<h1>Kiosk application</h1>
</header>
<main>
<p>You are viewing the <strong>local</strong> version.</p>
</main>
</body>
</html>

36
application/src/online/index.html

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="refresh" content="5">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f2f2f2;
}
header {
background-color: #333;
color: white;
padding: 1em;
text-align: center;
}
main {
margin: 2em;
}
</style>
<title>Kiosk application</title>
</head>
<body>
<header>
<h1>Kiosk application</h1>
</header>
<main>
<p>You are viewing the <strong>online</strong> version.</p>
</main>
</body>
</html>

18
application/src/static/style.css

@ -1,18 +0,0 @@
/* static/style.css */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f2f2f2;
}
header {
background-color: #333;
color: white;
padding: 1em;
text-align: center;
}
main {
margin: 2em;
}

29
application/src/templates/index.html

@ -1,29 +0,0 @@
<!-- templates/system_info.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<title>System Information</title>
</head>
<body>
<header>
<h1>System Information</h1>
</header>
<main>
<table>
<tr>
<th>Attribute</th>
<th>Value</th>
</tr>
{% for key, value in system_info.items() %}
<tr>
<td>{{ key }}</td>
<td>{{ value }}</td>
</tr>
{% endfor %}
</table>
</main>
</body>
</html>
Loading…
Cancel
Save