mirror of
https://github.com/StefBuwalda/dashboard_test.git
synced 2025-10-30 03:09:59 +00:00
Add services to db if they don't exist
This commit is contained in:
14
app.py
14
app.py
@@ -5,6 +5,7 @@ from mem import services, app, db
|
||||
import threading
|
||||
from flask_migrate import upgrade, stamp
|
||||
from pathlib import Path
|
||||
from models import service
|
||||
|
||||
|
||||
# Init and upgrade
|
||||
@@ -17,6 +18,19 @@ with app.app_context():
|
||||
# Upgrade db if any new migrations exist
|
||||
upgrade()
|
||||
|
||||
with app.app_context():
|
||||
if not db.session.query(service).first():
|
||||
for s in services:
|
||||
db.session.add(
|
||||
service(
|
||||
url=s.url,
|
||||
label=s.label,
|
||||
public_access=s.public,
|
||||
ping_method=s.ping_type,
|
||||
)
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def homepage():
|
||||
|
||||
Reference in New Issue
Block a user