2020-09-02 10:05:33 +00:00
|
|
|
"""
|
|
|
|
Run primitive keyserver
|
|
|
|
Only on node prime!
|
|
|
|
"""
|
|
|
|
import os
|
|
|
|
from flask import Flask
|
|
|
|
|
|
|
|
keyhome = os.path.join(os.path.expanduser('~'),'.komrade','.keyserver')
|
2020-09-02 09:57:07 +00:00
|
|
|
# if not os.path.exists(keyhome): os.makedirs(keyhome)
|
|
|
|
|
2020-09-02 10:05:33 +00:00
|
|
|
keyserver = 'komrade.app'
|
|
|
|
keyserver_port = 5566
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
|
|
async def init():
|
|
|
|
if not os.path.exists(keyhome):
|
|
|
|
from api import Api()
|
|
|
|
keyserver = await api.personate('keyserver')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
def hello():
|
|
|
|
return "Hello World!"
|
|
|
|
|
|
|
|
@app.route('/add/<name>/<key>')
|
|
|
|
def add(name,key):
|
|
|
|
key_fn = os.path.join(key_path,name+'.loc')
|
|
|
|
if os.path.exists(key_fn):
|
|
|
|
with open(key_fn,'wb') as of:
|
|
|
|
of.write(key)
|
|
|
|
return key
|
|
|
|
return None
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
# app.run(host='0.0.0.0',port=keyserver_port)
|
|
|
|
asyncio.run(init())
|