define the route to create a new key and send information
This commit is contained in:
		
							
								
								
									
										25
									
								
								aman/app.py
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								aman/app.py
									
									
									
									
									
								
							| @@ -2,6 +2,7 @@ | |||||||
|  |  | ||||||
| import json | import json | ||||||
| import os | import os | ||||||
|  | import subprocess | ||||||
|  |  | ||||||
| from flask import Flask, Response, request | from flask import Flask, Response, request | ||||||
| from json import JSONEncoder | from json import JSONEncoder | ||||||
| @@ -31,7 +32,7 @@ aman = AMAN() | |||||||
| app = Flask('AMAN') | app = Flask('AMAN') | ||||||
| version = '0.0.0' | version = '0.0.0' | ||||||
|  |  | ||||||
| with open(os.environ['AMAN_PATH'] + '\\VERSION') as file: | with open(os.path.join(os.environ['AMAN_PATH'], 'VERSION')) as file: | ||||||
|     version = file.readline() |     version = file.readline() | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
| @@ -47,6 +48,28 @@ def airports(): | |||||||
|     data = json.dumps({ 'version' : version, 'airports' : retval }, ensure_ascii=True) |     data = json.dumps({ 'version' : version, 'airports' : retval }, ensure_ascii=True) | ||||||
|     return Response(data, status=200, mimetype='application/json') |     return Response(data, status=200, mimetype='application/json') | ||||||
|  |  | ||||||
|  | @app.route('/aman/newuser') | ||||||
|  | def newUser(): | ||||||
|  |     toolpath = os.path.join(os.path.join(os.environ['AMAN_PATH'], 'tools'), 'KeyPairCreator.py') | ||||||
|  |     serverKeypath = os.path.join(os.path.join(os.path.join(AMAN.findConfigPath(), 'keys'), 'server'), 'server.key') | ||||||
|  |     clientKeypath = os.path.join(os.path.join(AMAN.findConfigPath(), 'keys'), 'clients') | ||||||
|  |  | ||||||
|  |     cmd = ['python', toolpath, '--directory=' + clientKeypath, '--publickey=' + serverKeypath] | ||||||
|  |  | ||||||
|  |     stdout = subprocess.check_output(cmd) | ||||||
|  |     keys = stdout.splitlines() | ||||||
|  |     server = keys[0].decode('ascii') | ||||||
|  |     public = keys[1].decode('ascii') | ||||||
|  |     private = keys[2].decode('ascii') | ||||||
|  |  | ||||||
|  |     dictionary = { | ||||||
|  |         'server' : server, | ||||||
|  |         'public' : public, | ||||||
|  |         'private' : private, | ||||||
|  |     } | ||||||
|  |     data = json.dumps(dictionary, ensure_ascii=True) | ||||||
|  |     return Response(data, status=200, mimetype='application/json') | ||||||
|  |  | ||||||
| @app.route('/aman/configuration/<icao>') | @app.route('/aman/configuration/<icao>') | ||||||
| def configuration(icao): | def configuration(icao): | ||||||
|     airport = aman.findAirport(icao.upper()) |     airport = aman.findAirport(icao.upper()) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user