mirror of
https://github.com/simon987/od-database.git
synced 2025-04-20 10:56:47 +00:00
Option to turn off SSL, moved secret keys to config.py, switched to sqlite WAL mode to avoid locked database problems
This commit is contained in:
parent
460357f183
commit
4f6d7f32ad
10
README.md
10
README.md
@ -9,6 +9,13 @@ git clone https://github.com/simon987/od-database
|
|||||||
cd od-database
|
cd od-database
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
Create `/config.py` and fill out the parameters. Empty config:
|
||||||
|
```python
|
||||||
|
CAPTCHA_SITE_KEY = ""
|
||||||
|
CAPTCHA_SECRET_KEY = ""
|
||||||
|
FLASK_SECRET = ""
|
||||||
|
USE_SSL = True
|
||||||
|
```
|
||||||
|
|
||||||
## Running
|
## Running
|
||||||
```bash
|
```bash
|
||||||
@ -16,5 +23,4 @@ python3 app.py
|
|||||||
```
|
```
|
||||||
You should be able to connect with your browser at `https://localhost:12345`
|
You should be able to connect with your browser at `https://localhost:12345`
|
||||||
|
|
||||||
*_Note: For now, you need to have the appropriate SSL certificates (cert.pem & privkey.pem) in /certificates. There will
|
*_Note: To use SSL you have to put the appropriate certificates in /certificates/_
|
||||||
be an option to disable SSL very soon_
|
|
||||||
|
16
app.py
16
app.py
@ -7,15 +7,16 @@ from database import Database, Website, InvalidQueryException
|
|||||||
from flask_recaptcha import ReCaptcha
|
from flask_recaptcha import ReCaptcha
|
||||||
import od_util
|
import od_util
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
import config
|
||||||
from flask_caching import Cache
|
from flask_caching import Cache
|
||||||
from task import TaskManager
|
from task import TaskManager
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
recaptcha = ReCaptcha(app=app,
|
recaptcha = ReCaptcha(app=app,
|
||||||
site_key="6LfpFFsUAAAAADgxNJ9PIE9UVO3SM69MCxjzYyOM",
|
site_key=config.CAPTCHA_SITE_KEY,
|
||||||
secret_key="6LfpFFsUAAAAADuzRvXZfq_nguS3RGj3FCA_2cc3")
|
secret_key=config.CAPTCHA_SECRET_KEY)
|
||||||
app.secret_key = "A very secret key"
|
app.secret_key = config.FLASK_SECRET
|
||||||
db = Database("db.sqlite3")
|
db = Database("db.sqlite3")
|
||||||
cache = Cache(app, config={'CACHE_TYPE': 'simple'})
|
cache = Cache(app, config={'CACHE_TYPE': 'simple'})
|
||||||
app.jinja_env.globals.update(truncate_path=od_util.truncate_path)
|
app.jinja_env.globals.update(truncate_path=od_util.truncate_path)
|
||||||
@ -182,6 +183,9 @@ def enqueue():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
if config.USE_SSL:
|
||||||
context.load_cert_chain('certificates/cert.pem', 'certificates/privkey.pem')
|
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||||
app.run("0.0.0.0", port=12345, ssl_context=context)
|
context.load_cert_chain('certificates/cert.pem', 'certificates/privkey.pem')
|
||||||
|
app.run("0.0.0.0", port=12345, ssl_context=context)
|
||||||
|
else:
|
||||||
|
app.run("0.0.0.0", port=12345)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
PRAGMA journal_mode=WAL;
|
||||||
|
|
||||||
CREATE TABLE Website (
|
CREATE TABLE Website (
|
||||||
|
|
||||||
id INTEGER PRIMARY KEY NOT NULL,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user