A ton more DB work
This commit is contained in:
parent
dbee0d65c2
commit
0e8121fcdb
4 changed files with 77 additions and 36 deletions
26
app/app.py
26
app/app.py
|
@ -1,16 +1,39 @@
|
||||||
|
from urllib import request
|
||||||
|
|
||||||
from flask import *
|
from flask import *
|
||||||
from os import path, walk
|
from os import path, walk
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
|
from sqlalchemy import create_engine
|
||||||
|
from sqlalchemy.orm import scoped_session,sessionmaker
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('config.ini')
|
config.read('config.ini')
|
||||||
|
|
||||||
instanceBranding = str(config['BRANDING']['instanceName'])
|
instanceBranding = str(config['BRANDING']['instanceName'])
|
||||||
instanceLocation = str(config['GENERAL']['instanceLocation'])
|
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__)
|
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('/')
|
@app.route('/')
|
||||||
def home():
|
def home():
|
||||||
|
@ -40,4 +63,5 @@ for extra_dir in extra_dirs:
|
||||||
extra_files.append(filename)
|
extra_files.append(filename)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
app.secret_key = 'super secret key'
|
||||||
app.run(debug=True, extra_files=extra_files)
|
app.run(debug=True, extra_files=extra_files)
|
||||||
|
|
|
@ -11,42 +11,53 @@
|
||||||
<h1>
|
<h1>
|
||||||
Register at {{ instanceLocation }}
|
Register at {{ instanceLocation }}
|
||||||
</h1>
|
</h1>
|
||||||
<label>
|
<form>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
placeholder="username"
|
||||||
|
type="text"
|
||||||
|
name="username"
|
||||||
|
size="10"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
placeholder="password"
|
||||||
|
type="password"
|
||||||
|
name="password"
|
||||||
|
size="10"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
placeholder="confirm password"
|
||||||
|
type="password"
|
||||||
|
name="confirm"
|
||||||
|
size="10"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
Agree to the rules
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="scales"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
<input
|
<input
|
||||||
placeholder="username"
|
type="submit"
|
||||||
type="text"
|
value="Register"
|
||||||
name="name"
|
|
||||||
size="10"
|
|
||||||
required
|
|
||||||
/>
|
/>
|
||||||
</label>
|
</form>
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
<input
|
|
||||||
placeholder="password"
|
|
||||||
type="password"
|
|
||||||
name="password"
|
|
||||||
size="10"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
Agree to the rules
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
name="scales"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<input
|
|
||||||
type="submit"
|
|
||||||
value="Register"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
[BRANDING]
|
[BRANDING]
|
||||||
instanceName = NyxAsk Sample Config
|
instanceName = NyxAsk Sample Config
|
||||||
instanceLocatiom = 'ask.example.com'
|
instanceLocation = 'ask.example.com'
|
||||||
|
|
||||||
|
[DATABASE]
|
||||||
|
username = nyxask
|
||||||
|
password = nyxask
|
||||||
|
name = nyxask
|
|
@ -1,2 +1,3 @@
|
||||||
flask
|
flask
|
||||||
flask-sqlalchemy
|
flask-sqlalchemy
|
||||||
|
psycopg2
|
Loading…
Add table
Reference in a new issue