mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
path to document file is now configurable, flask secret is now also taken from configuration
This commit is contained in:
parent
bd19dd3e55
commit
c5660986d6
@ -1,3 +1,10 @@
|
||||
[Document]
|
||||
documentPath=demo.ncdb
|
||||
|
||||
[Security]
|
||||
# run python generate-secret-key.py and paste the result below
|
||||
flaskSecretKey=
|
||||
|
||||
[Network]
|
||||
port=5000
|
||||
certPath=cert.crt
|
||||
|
5
generate-secret-key.py
Normal file
5
generate-secret-key.py
Normal file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import base64
|
||||
|
||||
print(base64.b64encode(os.urandom(24)))
|
5
run.sh
5
run.sh
@ -1,6 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
export FLASK_DEBUG=0
|
||||
export FLASK_APP=src/app.py
|
||||
|
||||
flask run
|
||||
python src/app.py
|
22
src/app.py
22
src/app.py
@ -1,22 +1,27 @@
|
||||
import os
|
||||
|
||||
import bcrypt
|
||||
import configparser
|
||||
import os
|
||||
from flask import Flask, request, send_from_directory
|
||||
from flask import render_template, redirect
|
||||
from flask_cors import CORS
|
||||
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user
|
||||
from flask_restful import Api
|
||||
|
||||
from expanded_note import ExpandedNote
|
||||
from move_after_note import MoveAfterNote
|
||||
from move_before_note import MoveBeforeNote
|
||||
from move_to_note import MoveToNote
|
||||
from notes import Notes
|
||||
from notes_children import NotesChildren
|
||||
|
||||
from expanded_note import ExpandedNote
|
||||
from move_before_note import MoveBeforeNote
|
||||
from sql import connect
|
||||
from tree import Tree
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read('config.ini')
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = 'dshjkjsdhfk9832fsdlhf'
|
||||
app.secret_key = config['Security']['flaskSecretKey']
|
||||
|
||||
class User(UserMixin):
|
||||
pass
|
||||
@ -36,9 +41,6 @@ def logout():
|
||||
logout_user()
|
||||
return redirect('login')
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read('config.ini')
|
||||
|
||||
user = User()
|
||||
user.id = config['Login']['username']
|
||||
|
||||
@ -46,6 +48,10 @@ port = config['Network']['port']
|
||||
certPath = config['Network']['certPath']
|
||||
certKeyPath = config['Network']['certKeyPath']
|
||||
|
||||
documentPath = config['Document']['documentPath']
|
||||
|
||||
connect(documentPath)
|
||||
|
||||
hashedPassword = config['Login']['password-hash'].encode('utf-8')
|
||||
|
||||
@app.route('/login', methods=['POST'])
|
||||
|
@ -1,5 +1,5 @@
|
||||
import sqlite3
|
||||
import base64
|
||||
import sqlite3
|
||||
|
||||
def dict_factory(cursor, row):
|
||||
d = {}
|
||||
@ -11,8 +11,10 @@ def dict_factory(cursor, row):
|
||||
|
||||
return d
|
||||
|
||||
conn = sqlite3.connect('demo.ncdb')
|
||||
conn.row_factory = dict_factory
|
||||
def connect(documentPath):
|
||||
global conn
|
||||
conn = sqlite3.connect(documentPath)
|
||||
conn.row_factory = dict_factory
|
||||
|
||||
def insert(tablename, rec):
|
||||
keys = ','.join(rec.keys())
|
||||
|
Loading…
x
Reference in New Issue
Block a user