add args flask example and update example env

This commit is contained in:
finn 2024-07-29 11:00:48 +00:00
parent 8c090273c7
commit 4bec4e9671
5 changed files with 52 additions and 9 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
gitea/ gitea/
.env .env
pmb-pf/ pmb-pf/
backend/giapp.py

View File

@ -8,7 +8,7 @@ RUN target=/root/.cache/pip \
COPY . . COPY . .
ENV FLASK_APP app.py ENV FLASK_APP giapp.py
# This might be scary to leave on # This might be scary to leave on
#ENV FLASK_ENV development #ENV FLASK_ENV development

View File

@ -1,6 +1,6 @@
import os import os
from datetime import datetime from datetime import datetime
from flask import Flask from flask import Flask, request
import mysql.connector import mysql.connector
@ -46,6 +46,10 @@ def listBlog():
rec = conn.query_titles() rec = conn.query_titles()
response = '' response = ''
ict = ''
arg1 = ''
arg2 = ''
for c in rec: for c in rec:
response = response + '<div> Log: ' + c + '</div>' response = response + '<div> Log: ' + c + '</div>'
@ -54,6 +58,28 @@ def listBlog():
response = response + '<div>Delta: ' + dtFormatted + '</div>' response = response + '<div>Delta: ' + dtFormatted + '</div>'
return response return response
@server.route('/args-test', methods=['GET'])
def listArgs():
good_token_i = str(os.getenv("TOKEN_I"))
ict = str(request.args.get('ict'))
arg1 = str(request.args.get('arg1'))
arg2 = str(request.args.get('arg2'))
response = ''
#INSECURE DEBUG response = response + '<div> gt:' + good_token_i + 'it:' + ict + '</div>'
if request.args.get('ict') == good_token_i:
response = response + '<div>Success</div>'
response = response + '<div>arg1' + arg1 + '</div>'
response = response + '<div>arg2' + arg2 + '</div>'
dt = datetime.now()
dtFormatted = dt.strftime("%Y-%m-%d %H:%M")
response = response + '<div>Delta: ' + dtFormatted + '</div>'
return response
if __name__ == '__main__': if __name__ == '__main__':
server.run() server.run()

View File

@ -31,6 +31,8 @@ services:
- MYSQL_USER=flasku - MYSQL_USER=flasku
#- MYSQL_PASSWORD=flaskp #- MYSQL_PASSWORD=flaskp
- MYSQL_PASSWORD=${DOTENV_MYSQL_FLASK_PASSWORD} - MYSQL_PASSWORD=${DOTENV_MYSQL_FLASK_PASSWORD}
- TOKEN_I=${DOTENV_TOKEN_I}
- TOKEN_C=${DOTENV_TOKEN_C}
#ports: #ports:
# - 8000:8000 # - 8000:8000
expose: expose:
@ -94,11 +96,12 @@ services:
- frontnet - frontnet
pmb: pmb:
build: #build:
args: # args:
GPG_PP: $BUILD_GPG_PP # GPG_PP: $BUILD_GPG_PP
context: pmb-pf # context: pmb-pf
dockerfile: Dockerfile # dockerfile: Dockerfile
image: site_pmb:latest
expose: expose:
- "25" - "25"
env_file: env_file:

17
dotenv
View File

@ -1,7 +1,20 @@
DOTENV_MYSQL_ROOT_PASSWORD_OLD=rootpass # Example .env file
DOTENV_MYSQL_ROOT_PASSWORD=rootpass DOTENV_MYSQL_ROOT_PASSWORD_OLD=rootp
DOTENV_MYSQL_ROOT_PASSWORD=rootp
DOTENV_MYSQL_GITEA_PASSWORD=giteap DOTENV_MYSQL_GITEA_PASSWORD=giteap
DOTENV_MYSQL_FLASK_PASSWORD=flaskp DOTENV_MYSQL_FLASK_PASSWORD=flaskp
GITEA_MAIL_FROM=
# Build ARG GPG_PP. May still need to be empty to avoid breakage.
BUILD_GPG_PP=
# Backend:
# Inconsequential token: minimal inconvenience if exposed
DOTENV_TOKEN_I=dti
# Consequential token: protect
DOTENV_TOKEN_C=dtc