Skip to content

Commit 41715d7

Browse files
committed
Fix #52 embed app name in app deployment template flask
add cors handling
1 parent 297e551 commit 41715d7

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ LOGGING_SMTP_CREDENTIALS_EMAIL=alerts@example.com
6161
LOGGING_SMTP_CREDENTIALS_PASSWORD=changeme
6262
LOGGING_SMTP_SECURE=()
6363
LOGGING_SMTP_TIMEOUT=3
64+
65+
CORS_ALLOWED_HOST=https://example.com

app.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"CONTAINER_HOSTING_SSH_SETUP_HANDLER_API_KEY"
5858
)
5959
DOKKU_WRAPPER_FULL_PATH = os.getenv("DOKKU_WRAPPER_FULL_PATH")
60+
CORS_ALLOWED_HOST = os.getenv("CORS_ALLOWED_HOST")
6061
# Default port to 5000
6162
# See https://dokku.com/docs~v0.15.5/networking/port-management/#:~:text=Applications%20not%20using-,EXPOSE,-Any%20application%20that
6263

@@ -146,6 +147,7 @@ async def homepage(request):
146147
"github_authorize_url_existing_repo": github_authorize_url_existing_repo,
147148
"request": request,
148149
},
150+
headers={"Access-Control-Allow-Origin": CORS_ALLOWED_HOST},
149151
)
150152

151153

@@ -577,6 +579,13 @@ def add_flask_quickstart():
577579
f"./tmp-cloned-repos/{APP_NAME}/src",
578580
dirs_exist_ok=True,
579581
)
582+
# Embed APP_NAME into deployed app
583+
subprocess.run(
584+
f"sed -i 's/Flaskr/Flaskr {APP_NAME}/g' web/templates/base.html",
585+
shell=True,
586+
cwd=f"./tmp-cloned-repos/{APP_NAME}/src",
587+
)
588+
580589
# add/commit framework files to repo
581590
index = repo.index
582591
index.add([f"{BASE_PATH}tmp-cloned-repos/{APP_NAME}/src/web"])

0 commit comments

Comments
 (0)