67 lines
1.9 KiB
Python
67 lines
1.9 KiB
Python
from urllib import request
|
|
|
|
from flask import *
|
|
from os import path, walk
|
|
|
|
import hashlib
|
|
|
|
import configparser
|
|
|
|
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import scoped_session,sessionmaker
|
|
|
|
config = configparser.ConfigParser()
|
|
config.read('config.ini')
|
|
|
|
instanceBranding = str(config['BRANDING']['instanceName'])
|
|
instanceLocation = str(config['BRANDING']['instanceLocation'])
|
|
|
|
databaseUsername = str(config['DATABASE']['username'])
|
|
databasePassword = str(config['DATABASE']['password'])
|
|
databaseName = str(config['DATABASE']['name'])
|
|
|
|
engine=create_engine("postgresql://" + databaseUsername + ":" + databasePassword + "@localhost/" + databaseName)
|
|
db=scoped_session(sessionmaker(bind=engine))
|
|
|
|
app = Flask(__name__)
|
|
|
|
def encrypt(data):
|
|
hash = hashlib.sha512()
|
|
data = data.encode('utf-8')
|
|
hash.update(data)
|
|
hash = hash.hexdigest()
|
|
# print(str(hash))
|
|
return hash
|
|
|
|
#encrypt("hi")
|
|
|
|
@app.route('/')
|
|
def home():
|
|
return render_template('index.j2', instanceLocation=instanceLocation, instanceBranding=instanceBranding)
|
|
|
|
|
|
@app.route('/auth/login/')
|
|
def login():
|
|
return render_template('login.j2', instanceLocation=instanceLocation, instanceBranding=instanceBranding)
|
|
|
|
@app.route('/auth/register/')
|
|
def register():
|
|
return render_template('register.j2', instanceLocation=instanceLocation, instanceBranding=instanceBranding)
|
|
|
|
@app.route('/assets/css/index.css')
|
|
def index_css():
|
|
return send_from_directory('static/assets/css', 'index.css')
|
|
|
|
|
|
extra_dirs = ['app/templates', 'static/assets/css']
|
|
extra_files = extra_dirs[:]
|
|
for extra_dir in extra_dirs:
|
|
for dirname, dirs, files in walk(extra_dir):
|
|
for filename in files:
|
|
filename = path.join(dirname, filename)
|
|
if path.isfile(filename):
|
|
extra_files.append(filename)
|
|
|
|
if __name__ == '__main__':
|
|
app.secret_key = 'super secret key'
|
|
app.run(debug=True, extra_files=extra_files)
|