smol changes

This commit is contained in:
rra 2020-06-24 19:19:19 +02:00
parent 22c6985ae2
commit cf5fd5df15

View File

@ -50,20 +50,7 @@ requests_log.propagate = True
DOMAIN = 'https://my-example.com'
USERNAME = 'alice'
def public_key():
"""
Use commandline openssl to generate a public and private key
"""
if not os.path.exists('public.pem'):
os.system('openssl genrsa -out private.pem 2048')
os.system('openssl rsa -in private.pem -outform PEM -pubout -out public.pem')
else:
public_key = open('public.pem').read()
public_key = public_key.replace('\n','\\n') #public key shouldn't contain verbatim linebreaks in json
return public_key
key = get_key(f'{DOMAIN}/users/{USERNAME}') #generate public_key on first launch
key = get_key(f'{DOMAIN}/users/{USERNAME}') #generate keypair on first launch
#Flask
app = flask.Flask(__name__)
@ -114,7 +101,6 @@ def post():
activity=json.loads(flask.render_template('create.json',
domain=DOMAIN, actor=USERNAME))
http_sig = HTTPSigAuth(key, headers)
url = 'https://post.lurk.org/inbox'
@ -122,9 +108,7 @@ def post():
body = json.dumps(activity)
headers = http_sig.sign(url,body)
#signed_headers = sign_header('private.pem', DOMAIN+'/users/'+USERNAME+'#main-key','https://post.lurk.org', json.dumps(json_message))
r = requests.post(url, json=body, headers=headers)
html = f'Status code <pre>{r.status_code}</pre></br>Response Headers: <pre>{r.headers}</pre></br></br> json message: <pre>{r.request.body}</pre></br></br> Request headers: <pre>{r.request.headers}</pre>'