mirror of
				https://github.com/simon987/od-database.git
				synced 2025-11-04 06:56:52 +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
 | 
			
		||||
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
 | 
			
		||||
```bash
 | 
			
		||||
@ -16,5 +23,4 @@ python3 app.py
 | 
			
		||||
```
 | 
			
		||||
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 
 | 
			
		||||
be an option to disable SSL very soon_
 | 
			
		||||
*_Note: To use SSL you have to put the appropriate certificates in /certificates/_
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								app.py
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								app.py
									
									
									
									
									
								
							@ -7,15 +7,16 @@ from database import Database, Website, InvalidQueryException
 | 
			
		||||
from flask_recaptcha import ReCaptcha
 | 
			
		||||
import od_util
 | 
			
		||||
import sqlite3
 | 
			
		||||
import config
 | 
			
		||||
from flask_caching import Cache
 | 
			
		||||
from task import TaskManager
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
app = Flask(__name__)
 | 
			
		||||
recaptcha = ReCaptcha(app=app,
 | 
			
		||||
                      site_key="6LfpFFsUAAAAADgxNJ9PIE9UVO3SM69MCxjzYyOM",
 | 
			
		||||
                      secret_key="6LfpFFsUAAAAADuzRvXZfq_nguS3RGj3FCA_2cc3")
 | 
			
		||||
app.secret_key = "A very secret key"
 | 
			
		||||
                      site_key=config.CAPTCHA_SITE_KEY,
 | 
			
		||||
                      secret_key=config.CAPTCHA_SECRET_KEY)
 | 
			
		||||
app.secret_key = config.FLASK_SECRET
 | 
			
		||||
db = Database("db.sqlite3")
 | 
			
		||||
cache = Cache(app, config={'CACHE_TYPE': 'simple'})
 | 
			
		||||
app.jinja_env.globals.update(truncate_path=od_util.truncate_path)
 | 
			
		||||
@ -182,6 +183,9 @@ def enqueue():
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
 | 
			
		||||
    context.load_cert_chain('certificates/cert.pem', 'certificates/privkey.pem')
 | 
			
		||||
    app.run("0.0.0.0", port=12345, ssl_context=context)
 | 
			
		||||
    if config.USE_SSL:
 | 
			
		||||
        context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
 | 
			
		||||
        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 (
 | 
			
		||||
 | 
			
		||||
  id INTEGER PRIMARY KEY NOT NULL,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user