#!/usr/bin/env python
# -*- coding: utf-8 -*-

# ephemeral by st0le
# quick way share text between your network devices 

from flask import Flask, request, render_template, redirect, url_for
db = {}
app = Flask(__name__)

@app.route('/')
def get():
    ip = request.remote_addr
    return render_template("index.html", text = db.get(ip, ''))

@app.route('/', methods=['POST'])
def post():
    ip, content = request.remote_addr, request.form.get('text')
    if len(content) == 0:
        del db[ip]
    else:
        db[ip] = content
    return redirect(url_for('get'))

if __name__ == "__main__":
    app.run(host="0.0.0.0")
@@ -215,16 +215,376 @@
 ame__)%0A%0A
+def get_client_ip(request):%0A    # PythonAnywhere.com calls our service through a loabalancer%0A    # the remote_addr is therefore the IP of the loaabalancer, PythonAnywhere stores Client IP in header%0A    if request.headers%5B'X-Real-IP'%5D: return request.headers%5B'X-Real-IP'%5D%0A    return request.remote_addr%0A%0A%0Aif __name__ == %22__main__%22:%0A    app.run(host=%220.0.0.0%22)%0A%0A
 @app.rou
@@ -611,35 +611,38 @@
    ip = 
-request.remote_addr
+get_client_ip(request)
 %0A    ret
@@ -763,35 +763,38 @@
 ntent = 
-request.remote_addr
+get_client_ip(request)
 , reques

Fix for PythonAnywhere LoadBalancer IP