mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	configurable port plus support for SSL
This commit is contained in:
		
							parent
							
								
									f80f073874
								
							
						
					
					
						commit
						3c924afbca
					
				
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -6,3 +6,5 @@ yarn-error.log
 | 
				
			|||||||
app.pyc
 | 
					app.pyc
 | 
				
			||||||
demo.ncdb
 | 
					demo.ncdb
 | 
				
			||||||
config.ini
 | 
					config.ini
 | 
				
			||||||
 | 
					cert.key
 | 
				
			||||||
 | 
					cert.crt
 | 
				
			||||||
@ -1,8 +1,13 @@
 | 
				
			|||||||
 | 
					[Network]
 | 
				
			||||||
 | 
					port=5000
 | 
				
			||||||
 | 
					certPath=cert.crt
 | 
				
			||||||
 | 
					certKeyPath=cert.key
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[Login]
 | 
					[Login]
 | 
				
			||||||
# Enter below credentials with with which you want to authenticate to Notecase web app
 | 
					# Enter below credentials with with which you want to authenticate to Notecase web app
 | 
				
			||||||
username=adam
 | 
					username=your_username
 | 
				
			||||||
# This is bcrypt password hash. You can use generate-password.py (in this directory) to hash your password
 | 
					# This is bcrypt password hash. You can use generate-password.py (in this directory) to hash your password
 | 
				
			||||||
password-hash=$2b$12$4Ia5lYbbpOv3pxxdoDgjUeAJ9z4FhqyEhhX52ra78FH03wPGx8zGu
 | 
					password-hash=$2b$12$FHT8keXp3BGTfzAV/VnrkuLpkwN8Vpj5iIh4RwCbHTNWYSBI9hGAK
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[Sync]
 | 
					[Sync]
 | 
				
			||||||
sync-server-url=https://localhost:57201
 | 
					sync-server-url=https://localhost:57201
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										16
									
								
								generate-cert.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								generate-cert.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					openssl genrsa -des3 -out cert.key 2048
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					openssl req -new -key cert.key -out cert.csr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Remove passphrase from key
 | 
				
			||||||
 | 
					cp cert.key cert.key.org
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					openssl rsa -in cert.key.org -out cert.key
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Generate self signed certificate
 | 
				
			||||||
 | 
					openssl x509 -req -days 730 -in cert.csr -signkey cert.key -out cert.crt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					rm cert.key.org
 | 
				
			||||||
 | 
					rm cert.csr
 | 
				
			||||||
							
								
								
									
										6
									
								
								run-debug.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								run-debug.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export FLASK_DEBUG=0
 | 
				
			||||||
 | 
					export FLASK_APP=src/app.py
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					flask run
 | 
				
			||||||
							
								
								
									
										2
									
								
								run.sh
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								run.sh
									
									
									
									
									
								
							@ -1,6 +1,6 @@
 | 
				
			|||||||
#!/bin/sh
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export FLASK_DEBUG=1
 | 
					export FLASK_DEBUG=0
 | 
				
			||||||
export FLASK_APP=src/app.py
 | 
					export FLASK_APP=src/app.py
 | 
				
			||||||
 | 
					
 | 
				
			||||||
flask run
 | 
					flask run
 | 
				
			||||||
@ -42,6 +42,10 @@ config.read('config.ini')
 | 
				
			|||||||
user = User()
 | 
					user = User()
 | 
				
			||||||
user.id = config['Login']['username']
 | 
					user.id = config['Login']['username']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					port = config['Network']['port']
 | 
				
			||||||
 | 
					certPath = config['Network']['certPath']
 | 
				
			||||||
 | 
					certKeyPath = config['Network']['certKeyPath']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
hashedPassword = config['Login']['password-hash'].encode('utf-8')
 | 
					hashedPassword = config['Login']['password-hash'].encode('utf-8')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@app.route('/login', methods=['POST'])
 | 
					@app.route('/login', methods=['POST'])
 | 
				
			||||||
@ -85,5 +89,5 @@ def load_user(user_id):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
api.add_resource(Notes, '/notes/<string:note_id>')
 | 
					api.add_resource(Notes, '/notes/<string:note_id>')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == "__main__":
 | 
				
			||||||
    app.run(host='0.0.0.0')
 | 
					    app.run(host='0.0.0.0', port=port, ssl_context = (certPath, certKeyPath))
 | 
				
			||||||
@ -44,7 +44,7 @@
 | 
				
			|||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    <link href="static/lib/bootstrap/css/bootstrap.css" rel="stylesheet">
 | 
					    <link href="stat/lib/bootstrap/css/bootstrap.css" rel="stylesheet">
 | 
				
			||||||
    <script src="static/lib/bootstrap/js/bootstrap.js"></script>
 | 
					    <script src="stat/lib/bootstrap/js/bootstrap.js"></script>
 | 
				
			||||||
  </body>
 | 
					  </body>
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user