mirror of
https://github.com/cwinfo/yggdrasil-map
synced 2025-06-26 12:49:23 +00:00
sendGraph.py updates
This commit is contained in:
@ -3,9 +3,9 @@ from database import NodeDB
|
||||
from graph import Node, Edge
|
||||
import traceback
|
||||
|
||||
def insert_graph_data(config, json_str):
|
||||
def insert_graph_data(config, data, mail, ip):
|
||||
try:
|
||||
graph_data = json.loads(json_str)
|
||||
graph_data = json.loads(data)
|
||||
except ValueError:
|
||||
return 'Invalid JSON'
|
||||
|
||||
@ -36,7 +36,7 @@ def insert_graph_data(config, json_str):
|
||||
|
||||
try:
|
||||
with NodeDB(config) as db:
|
||||
db.insert_graph(nodes, edges)
|
||||
db.insert_graph(nodes, edges)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
return 'Database failure'
|
||||
|
@ -9,9 +9,13 @@
|
||||
|
||||
<h3>Network map</h3>
|
||||
<p>The network page has a map of Hyperboria as it is now. The map is not complete since it is hard/impossible to get a full picture of the network. A rough estimate is that at least half of the nodes are pictured here, probably more. The nodes and links that are shown on the page are very likely to exist but this should not be taken as a guarantee.</p>
|
||||
|
||||
<h3>Node names</h3>
|
||||
<p>For now, node names are assigned manually. You can submit Pull Request to <a href="https://github.com/zielmicha/nodedb">nodedb</a> if you want to have your node named.
|
||||
In future this will be replaced by some reverse DNS system.
|
||||
|
||||
<h3>Contact</h3>
|
||||
<p>fc00 was orginally created by <em>Randati</em>. Currently fc00 is run by <em>zielmicha</em>.
|
||||
<p>fc00 was orginally created by <em>Randati</em>. fc00 is currently run by <em>zielmicha</em>.
|
||||
If you have something to say or you would like to help, contact him via michal@zielinscy.org.pl.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
15
web/web.py
15
web/web.py
@ -4,13 +4,15 @@ from graphData import insert_graph_data
|
||||
app = Flask(__name__)
|
||||
app.config.from_pyfile('web_config.cfg')
|
||||
|
||||
|
||||
@app.context_processor
|
||||
def add_ip():
|
||||
def get_ip():
|
||||
ip = request.headers['x-real-ip']
|
||||
if ip == '10.18.3.20':
|
||||
ip = request.headers['x-atomshare-real-ip']
|
||||
return dict(ip=ip)
|
||||
return ip
|
||||
|
||||
@app.context_processor
|
||||
def add_ip():
|
||||
return dict(ip=get_ip())
|
||||
|
||||
|
||||
@app.route('/')
|
||||
@ -26,8 +28,9 @@ def page_about():
|
||||
def page_sendGraph():
|
||||
print "Receiving graph from %s" % (request.remote_addr)
|
||||
|
||||
data = request.form['data']
|
||||
ret = insert_graph_data(app.config, data)
|
||||
data = request.form['data']
|
||||
mail = request.form.get('mail', 'none')
|
||||
ret = insert_graph_data(ip=get_ip(), config=app.config, data=data, mail=mail)
|
||||
if ret == None:
|
||||
return 'OK'
|
||||
else:
|
||||
|
Reference in New Issue
Block a user