INIT COMMIT
commit
1d5578aafb
|
|
@ -0,0 +1,24 @@
|
|||
# Use the official Python 3.9 slim image
|
||||
FROM python:3.9-slim
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the requirements file and install dependencies
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --upgrade pip && pip install -r requirements.txt
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
|
||||
# Set environment variables for production
|
||||
ENV FLASK_ENV=production
|
||||
ENV FLASK_APP=isalive.py
|
||||
ENV FLASK_RUN_HOST=0.0.0.0
|
||||
ENV FLASK_RUN_PORT=5050
|
||||
|
||||
# Expose port 7000 (the internal port where the app will run)
|
||||
EXPOSE 5050
|
||||
|
||||
# Use Gunicorn to serve the app on port 7000
|
||||
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5050", "run:app"]
|
||||
Binary file not shown.
|
|
@ -0,0 +1,53 @@
|
|||
from flask import Blueprint, render_template, request, g
|
||||
from datetime import datetime, date
|
||||
import sqlite3
|
||||
|
||||
|
||||
keep = Blueprint('keep', __name__,template_folder='templates')
|
||||
|
||||
def get_db():
|
||||
db = getattr(g, "_database", None)
|
||||
if db is None:
|
||||
db = g._database = sqlite3.connect("app/db/keepalive.db")
|
||||
return db
|
||||
|
||||
@keep.route('/keepalive/')
|
||||
def dispkeepalive():
|
||||
conn = get_db()
|
||||
c = conn.cursor()
|
||||
items_from_db = c.execute("""SELECT
|
||||
i.id, i.location, i.time, i.date
|
||||
FROM
|
||||
keepalive2 AS i
|
||||
ORDER BY i.id DESC
|
||||
""")
|
||||
#db_teardown(keep)
|
||||
items = []
|
||||
for row in items_from_db:
|
||||
item = {
|
||||
"id": row[0],
|
||||
"location": row[1],
|
||||
"time": row[2],
|
||||
"date": row[3]
|
||||
}
|
||||
items.append(item)
|
||||
|
||||
return render_template("keepaliveshowpage.html", items=items)
|
||||
|
||||
|
||||
@keep.route('/<location>/', methods=["POST"])
|
||||
def getalive(location):
|
||||
if request.method == "POST":
|
||||
conn = get_db()
|
||||
c = conn.cursor()
|
||||
c.execute("""INSERT INTO keepalive2
|
||||
(location, date, time)
|
||||
VALUES (?,?,?)""",
|
||||
(
|
||||
location,
|
||||
date.today().strftime("%m/%d/%y"),
|
||||
datetime.now().strftime("%H:%M:%S")
|
||||
)
|
||||
)
|
||||
conn.commit()
|
||||
return location
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
{% extends 'keepbase.html' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% if items %}
|
||||
<table class="table">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th scope="col">Location</th>
|
||||
<th scope="col">Date</th>
|
||||
<th scope="col">Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{% for item in items %}
|
||||
<tr>
|
||||
|
||||
<td>{{ item.location }}</td>
|
||||
<td>{{ item.date }}</td>
|
||||
<td>{{ item.time }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<h1 class="offset-lg-3">No items to show.</h1>
|
||||
{% endif %}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="user-scalable=no, width=device-width, height=device-height" />
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
|
||||
<link href="{{ url_for('static', filename='css/styles.css')}}" rel="stylesheet">
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.slim.js" integrity="sha256-HwWONEZrpuoh951cQD1ov2HUK5zA5DwJ1DNUXaM6FsY=" crossorigin="anonymous"></script>
|
||||
<title>
|
||||
{% block title %}{% endblock %}
|
||||
</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
version: '3.8'
|
||||
services:
|
||||
web:
|
||||
build: .
|
||||
ports:
|
||||
- "5050:5050"
|
||||
environment:
|
||||
- FLASK_ENV=production
|
||||
- SECRET_KEY=youSCUMMER
|
||||
volumes:
|
||||
- .:/app
|
||||
restart: always
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Flask
|
||||
gunicorn
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
from flask import Flask, g
|
||||
from app.keep import keep
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
app.register_blueprint(keep)
|
||||
|
||||
|
||||
@app.teardown_appcontext
|
||||
def close_connection(exception):
|
||||
db = getattr(g, "_database", None)
|
||||
if db is not None:
|
||||
db.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host = "0.0.0.0", debug = True, port = 5050)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
$CurlArgument = '-X', 'POST',
|
||||
'http://24.185.75.128:8889/bay/'
|
||||
$CURLEXE = 'C:\Program Files\Git\mingw64\bin\curl.exe'
|
||||
& $CURLEXE @CurlArgument
|
||||
Loading…
Reference in New Issue