forked from HsKA-OSGIS-archive/EurOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
162 lines (132 loc) · 4.61 KB
/
index.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# -*- coding: utf-8 -*-
from flask import Flask
# from flask.ext.sqlalchemy import SQLAlchemy
from flask import Flask, render_template, request, url_for
from sqlalchemy import select
from sqlalchemy import *
from sqlalchemy.orm import *
import geojson
import json
from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime
import psycopg2
import cgi
def shutdown_server():
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
func()
engine = create_engine('postgresql://postgres:postgres@localhost/postgres')
app = Flask(__name__)
# app.config.from_pyfile('config.py')
# db = SQLAlchemy(app)
metadata = MetaData(engine)
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base(metadata=metadata)
#
# class hska_exp(Base):
# __tablename__ = "hska_exp"
# ID= Column(Numeric, primary_key=True)
# Name= Column(Text(120))
# Lon= Column(Numeric(20))
# Lat= Column(Numeric(20))
# Date= Column(Text(10))
# Hour= Column(Text(10))
# ODL= Column(Numeric)
class hska_exp2(Base):
__tablename__ = "hska_exp2"
ID= Column(Numeric, primary_key=True)
Name= Column(Text(120))
Lon= Column(Numeric(20))
Lat= Column(Numeric(20))
Date= Column(Text(10))
Hour= Column(Text(10))
ODL= Column(Numeric)
#geocoll = session.query(hska_exp).all()
# i=0
# namef='tralari'
# file=open('radiologic.json', 'w')
# file.write('[{\n\t')
# for hska_exp in session.query(hska_exp).order_by(asc(hska_exp.ID)).all():
# namei=hska_exp.Name
# if namei!=namef and i==0:
# file.write('"name": "'+ hska_exp.Name+'",\n\t"lon": '+str(hska_exp.Lon)+',\n\t"lat": '+str(hska_exp.Lat)+',\n\t"radio": [["'+hska_exp.Date+'T'+hska_exp.Hour+'Z",\n\t'+str(hska_exp.ODL)+']')
# if namei!=namef and i!=0:
# file.write(']\n},\n{\n\t"name": "'+ hska_exp.Name+'",\n\t"lon": '+str(hska_exp.Lon)+',\n\t"lat": '+str(hska_exp.Lat)+',\n\t"radio": [["'+hska_exp.Date+'T'+hska_exp.Hour+'Z",\n\t'+str(hska_exp.ODL)+']')
# if namei==namef:
# file.write(',\n\t["'+hska_exp.Date+'T'+hska_exp.Hour+'Z",\n\t'+str(hska_exp.ODL)+']')
# namef=hska_exp.Name
# i=i+1
# file.write(']\n}]')
# file.close()
# Base = declarative_base(metadata=metadata)
#
# class hska_exp(Base):
# __tablename__ = "hska_exp"
# ID= Column(Numeric, primary_key=True)
# Name= Column(Text(120))
# Lon= Column(Numeric(20))
# Lat= Column(Numeric(20))
# Date= Column(Text(10))
# Hour= Column(Text(10))
# ODL= Column(Numeric)
i=0
namef='tralari'
file=open(r'static\radiologic.json', 'w')
file.write('[{\n\t')
for hska_exp2 in session.query(hska_exp2).order_by(asc(hska_exp2.ID)).all():
namei=hska_exp2.Name
if namei!=namef and i==0:
file.write('"name": "'+ hska_exp2.Name+'",\n\t"lon": '+str(hska_exp2.Lon)+',\n\t"lat": '+str(hska_exp2.Lat)+',\n\t"radio": [["'+hska_exp2.Date+'T'+hska_exp2.Hour+'Z",\n\t'+str(hska_exp2.ODL)+']')
if namei!=namef and i!=0:
file.write(']\n},\n{\n\t"name": "'+ hska_exp2.Name+'",\n\t"lon": '+str(hska_exp2.Lon)+',\n\t"lat": '+str(hska_exp2.Lat)+',\n\t"radio": [["'+hska_exp2.Date+'T'+hska_exp2.Hour+'Z",\n\t'+str(hska_exp2.ODL)+']')
if namei==namef:
file.write(',\n\t["'+hska_exp2.Date+'T'+hska_exp2.Hour+'Z",\n\t'+str(hska_exp2.ODL)+']')
namef=hska_exp2.Name
i=i+1
file.write(']\n}]')
file.close()
# Set "homepage" to index.html
@app.route('/')
def index():
return render_template('index.html')
@app.route('/index.html')
def index2():
return render_template('index.html')
@app.route('/html/ar.html')
def ar():
return render_template('ar.html')
@app.route('/html/cesium.html')
def cesium():
return render_template ('cesium.html')
@app.route('/html/radiologic.json',methods=['GET'])
def cesium2():
return json.dumps(geocoll)
# @app.route('/html/cesium.html', methods=['GET'])
# def areas_get():
# return geojson.dumps(geocoll)
@app.route('/html/be.html')
def be():
return render_template('be.html')
@app.route('/html/es.html')
def es():
return render_template('es.html')
@app.route('/html/information.html')
def information():
return render_template('information.html')
@app.route('/html/jp.html')
def js():
return render_template('jp.html')
@app.route('/html/vid.html')
def vid():
return render_template('vid.html')
with app.test_request_context():
url_for('static', filename='radiologic.json')
@app.route('/shutdown', methods=['POST'])
def shutdown():
shutdown_server()
return 'Server shutting down...'
if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0')