SQL Connection DOne

This commit is contained in:
Václav Španinger 2023-08-07 13:51:20 +02:00
parent 6d5d037f44
commit b8340244a2
3 changed files with 22 additions and 6 deletions

BIN
app.db Normal file

Binary file not shown.

View File

@ -42,14 +42,30 @@ def calculate_ram_percent(stats, status):
load_dotenv() load_dotenv()
scheduler = APScheduler() basedir = os.path.abspath(os.path.dirname(__file__))
app = Flask(__name__) app = Flask(__name__)
#SESSION
app.secret_key = "sdasdsadasdasdasdadadaasd53563da" app.secret_key = "sdasdsadasdasdasdadadaasd53563da"
app.permanent_session_lifetime = timedelta(days=1) app.permanent_session_lifetime = timedelta(days=1)
#DATABASE
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'+ os.path.join(basedir, 'app.db')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
class users(db.Model):
_id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255))
password = db.Column(db.String(255))
def __init__(self, name, password):
self.name = name
self.password = password
scheduler = APScheduler()
client = docker.from_env() client = docker.from_env()
# db = SQLAlchemy(app)
# migrate = Migrate(app, db) # migrate = Migrate(app, db)
# login_manager.init_app(app) # login_manager.init_app(app)
@ -133,4 +149,6 @@ def scheduleTasks():
if __name__ == '__main__': if __name__ == '__main__':
# scheduler.add_job(id = 'scheduled_tasks', func=scheduleTasks, trigger="interval", seconds=60) # scheduler.add_job(id = 'scheduled_tasks', func=scheduleTasks, trigger="interval", seconds=60)
# scheduler.start() # scheduler.start()
app.app_context().push()
db.create_all()
app.run(host=os.getenv('IP'), port=os.getenv('port'), debug=True) app.run(host=os.getenv('IP'), port=os.getenv('port'), debug=True)

View File

@ -28,7 +28,6 @@
<div class="square-content" onclick="openModalForContainer('{{container.id}}')"> <div class="square-content" onclick="openModalForContainer('{{container.id}}')">
<!-- Content for the square item --> <!-- Content for the square item -->
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<img height="60" width="60" <img height="60" width="60"
src="https://raw.githubusercontent.com/walkxcode/dashboard-icons/main/svg/nginx.svg" alt=""> src="https://raw.githubusercontent.com/walkxcode/dashboard-icons/main/svg/nginx.svg" alt="">
<div class="form-check form-switch form-check-reverse"> <div class="form-check form-switch form-check-reverse">
@ -80,7 +79,6 @@
route = (status == 'running' ? 'stop' : 'start') route = (status == 'running' ? 'stop' : 'start')
method = (status == 'running' ? 'DELETE' : 'POST') method = (status == 'running' ? 'DELETE' : 'POST')
const xhttp = new XMLHttpRequest(); const xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () { xhttp.onreadystatechange = function () {