2
0
mirror of https://github.com/ComradCollective/Comrad synced 2024-11-17 21:25:37 +00:00
Comrad/p2p/keyserver.py

38 lines
825 B
Python
Raw Normal View History

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())