-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f54c58a
commit 70feaba
Showing
14 changed files
with
295 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
"""Flask app configuration.""" | ||
from os import environ, path | ||
|
||
from dotenv import load_dotenv | ||
|
||
basedir = path.abspath(path.dirname(__file__)) | ||
load_dotenv(path.join(basedir, '.env')) | ||
load_dotenv(path.join(basedir, ".env")) | ||
|
||
|
||
class Config: | ||
"""Global configuration variables.""" | ||
|
||
# General Config | ||
SECRET_KEY = environ.get('SECRET_KEY') | ||
FLASK_APP = environ.get('FLASK_APP') | ||
FLASK_ENV = environ.get('FLASK_ENV') | ||
SECRET_KEY = environ.get("SECRET_KEY") | ||
FLASK_APP = environ.get("FLASK_APP") | ||
FLASK_ENV = environ.get("FLASK_ENV") | ||
|
||
# Database | ||
SQLALCHEMY_DATABASE_URI = environ.get('SQLALCHEMY_DATABASE_URI') | ||
SQLALCHEMY_DATABASE_URI = environ.get("SQLALCHEMY_DATABASE_URI") | ||
SQLALCHEMY_TRACK_MODIFICATIONS = False | ||
SQLALCHEMY_DATABASE_HOST = 'hackers-data-do-user-1142484-0.db.ondigitalocean.com' | ||
SQLALCHEMY_DATABASE_TABLE = 'commands' | ||
SQLALCHEMY_DATABASE_NAME = environ.get('SQLALCHEMY_DATABASE_NAME') | ||
SQLALCHEMY_CONNECT_ARGS = {'ssl': {'ca': './creds/ca-certificate.crt'}} | ||
SQLALCHEMY_DATABASE_HOST = "hackers-data-do-user-1142484-0.db.ondigitalocean.com" | ||
SQLALCHEMY_DATABASE_TABLE = "commands" | ||
SQLALCHEMY_DATABASE_NAME = environ.get("SQLALCHEMY_DATABASE_NAME") | ||
SQLALCHEMY_CONNECT_ARGS = {"ssl": {"ca": "./creds/ca-certificate.crt"}} | ||
|
||
# Flask-Assets | ||
LESS_BIN = environ.get('LESS_BIN') | ||
ASSETS_DEBUG = environ.get('ASSETS_DEBUG') | ||
LESS_RUN_IN_DEBUG = environ.get('LESS_RUN_IN_DEBUG') | ||
LESS_BIN = environ.get("LESS_BIN") | ||
ASSETS_DEBUG = environ.get("ASSETS_DEBUG") | ||
LESS_RUN_IN_DEBUG = environ.get("LESS_RUN_IN_DEBUG") | ||
|
||
# Static Assets | ||
STATIC_FOLDER = 'static' | ||
TEMPLATES_FOLDER = 'templates' | ||
COMPRESSOR_DEBUG = environ.get('COMPRESSOR_DEBUG') | ||
|
||
STATIC_FOLDER = "static" | ||
TEMPLATES_FOLDER = "templates" | ||
COMPRESSOR_DEBUG = environ.get("COMPRESSOR_DEBUG") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,32 @@ | ||
"""Form classes.""" | ||
from wtforms import ( | ||
Form, | ||
StringField, | ||
PasswordField, | ||
SubmitField, | ||
SelectField | ||
) | ||
from wtforms import Form, PasswordField, SelectField, StringField, SubmitField | ||
from wtforms.validators import DataRequired, Length, Optional | ||
|
||
|
||
class DatabaseForm(Form): | ||
"""Database connection Form.""" | ||
|
||
flavor = SelectField( | ||
'Database Flavor', | ||
validators=[DataRequired(message='Select a type of database.')], | ||
choices=['MySQL', 'Postgres', 'SQLLite'] | ||
) | ||
host = StringField( | ||
'Email', | ||
validators=[DataRequired(message='Enter a hostname.')] | ||
"Database Flavor", | ||
validators=[DataRequired(message="Select a type of database.")], | ||
choices=["MySQL", "Postgres", "SQLLite"], | ||
) | ||
host = StringField("Email", validators=[DataRequired(message="Enter a hostname.")]) | ||
port = StringField( | ||
'Port', | ||
"Port", | ||
validators=[ | ||
DataRequired(message='Enter a port.'), | ||
Length(min=4, message='Enter a valid port.')] | ||
DataRequired(message="Enter a port."), | ||
Length(min=4, message="Enter a valid port."), | ||
], | ||
) | ||
user = StringField( | ||
'Username', | ||
validators=[Length(min=6, message='Enter a valid email address.')] | ||
"Username", validators=[Length(min=6, message="Enter a valid email address.")] | ||
) | ||
password = PasswordField( | ||
'DB Password', | ||
validators=[DataRequired(message='Enter a password.')] | ||
"DB Password", validators=[DataRequired(message="Enter a password.")] | ||
) | ||
database = StringField( | ||
'Website', | ||
validators=[DataRequired(message='Enter a database name.')] | ||
) | ||
schema = StringField( | ||
'Schema', | ||
validators=[Optional()] | ||
"Website", validators=[DataRequired(message="Enter a database name.")] | ||
) | ||
submit = SubmitField('Connect') | ||
schema = StringField("Schema", validators=[Optional()]) | ||
submit = SubmitField("Connect") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,60 @@ | ||
"""Core route declaration.""" | ||
from flask import Blueprint, render_template | ||
from flask import Blueprint | ||
from flask import current_app as app | ||
from . import db | ||
from flask import render_template | ||
|
||
from . import db | ||
|
||
# Create Blueprint | ||
main_bp = Blueprint( | ||
'main_bp', __name__, | ||
template_folder='templates', | ||
static_folder='static' | ||
"main_bp", __name__, template_folder="templates", static_folder="static" | ||
) | ||
|
||
|
||
@main_bp.route('/') | ||
@main_bp.route("/") | ||
def home(): | ||
"""Database Table Selection Page.""" | ||
tables = db.engine.table_names() | ||
host = app.config['SQLALCHEMY_DATABASE_HOST'] | ||
db_name = app.config['SQLALCHEMY_DATABASE_NAME'] | ||
host = app.config["SQLALCHEMY_DATABASE_HOST"] | ||
db_name = app.config["SQLALCHEMY_DATABASE_NAME"] | ||
return render_template( | ||
'index.html', | ||
"index.html", | ||
tables=tables, | ||
title='Database Tables.', | ||
template='home-template', | ||
title="Database Tables.", | ||
template="home-template", | ||
host_name=host, | ||
table_summary=f'Displaying {len(tables)} tables found in database {db_name}:' | ||
table_summary=f"Displaying {len(tables)} tables found in database {db_name}:", | ||
) | ||
|
||
|
||
@main_bp.route('/database') | ||
@main_bp.route("/database") | ||
def database(): | ||
"""Database Configuration Page.""" | ||
return render_template( | ||
'index.html', | ||
title='Connect a Database', | ||
template='database-template', | ||
body="This is an example homepage, served with Flask." | ||
"index.html", | ||
title="Connect a Database", | ||
template="database-template", | ||
body="This is an example homepage, served with Flask.", | ||
) | ||
|
||
|
||
@main_bp.route('/users') | ||
@main_bp.route("/users") | ||
def users(): | ||
"""Users Page.""" | ||
return render_template( | ||
'index.html', | ||
title='Users', | ||
template='users-template', | ||
body="This is an example homepage, served with Flask." | ||
"index.html", | ||
title="Users", | ||
template="users-template", | ||
body="This is an example homepage, served with Flask.", | ||
) | ||
|
||
|
||
@main_bp.route('/settings') | ||
@main_bp.route("/settings") | ||
def settings(): | ||
"""Settings Page.""" | ||
return render_template( | ||
'index.html', | ||
title='Settings', | ||
template='settings-template', | ||
body="This is an example homepage, served with Flask." | ||
"index.html", | ||
title="Settings", | ||
template="settings-template", | ||
body="This is an example homepage, served with Flask.", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.