Исправлена ошибка создания JS файлов
This commit is contained in:
parent
6db712b31b
commit
344763fc1d
20
main.py
20
main.py
@ -41,7 +41,8 @@ user_email = ""
|
|||||||
|
|
||||||
|
|
||||||
def remove_java():
|
def remove_java():
|
||||||
os.remove('static/js/safe_app_school/mapbasics.js')
|
global help_arg
|
||||||
|
os.remove(help_arg)
|
||||||
|
|
||||||
|
|
||||||
def norm_data(datatime, date_or_time, r=False):
|
def norm_data(datatime, date_or_time, r=False):
|
||||||
@ -312,6 +313,7 @@ def safe_app_school_setting():
|
|||||||
|
|
||||||
@app.route('/safeappschool/go/<string:point>')
|
@app.route('/safeappschool/go/<string:point>')
|
||||||
def safe_app_school_go(point):
|
def safe_app_school_go(point):
|
||||||
|
global help_arg
|
||||||
if current_user.is_authenticated:
|
if current_user.is_authenticated:
|
||||||
data_session = db_session.create_session()
|
data_session = db_session.create_session()
|
||||||
address = data_session.query(UserPoint).filter(UserPoint.user == current_user.id).first()
|
address = data_session.query(UserPoint).filter(UserPoint.user == current_user.id).first()
|
||||||
@ -320,20 +322,24 @@ def safe_app_school_go(point):
|
|||||||
with open('static/js/safe_app_school/mapbasics_templates.js', 'r', encoding='utf-8') as file:
|
with open('static/js/safe_app_school/mapbasics_templates.js', 'r', encoding='utf-8') as file:
|
||||||
new_file = file.read().split('<point1>')
|
new_file = file.read().split('<point1>')
|
||||||
new_file = new_file[
|
new_file = new_file[
|
||||||
0] + f'\'{address.home_address if point == "home" else address.school_address}\'' \
|
0] + f'\'{str(address.home_address).strip() if point == "home" else str(address.school_address).strip()}\'' \
|
||||||
+ new_file[1]
|
+ new_file[1]
|
||||||
new_file = new_file.split('<point2>')
|
new_file = new_file.split('<point2>')
|
||||||
new_file = new_file[
|
new_file = new_file[
|
||||||
0] + f'\'{address.school_address if point == "home" else address.home_address}\'' + \
|
0] + f'\'{str(address.school_address).strip() if point == "home" else str(address.home_address).strip()}\'' + \
|
||||||
new_file[1]
|
new_file[1]
|
||||||
with open('static/js/safe_app_school/mapbasics.js', 'w', encoding='utf-8') as new_js:
|
with open(f'static/js/safe_app_school/{str(current_user.id)}mapbasics.js', 'w',
|
||||||
|
encoding='utf-8') as new_js:
|
||||||
new_js.write(new_file)
|
new_js.write(new_file)
|
||||||
t = Timer(1, remove_java, args=None, kwargs=None)
|
help_arg = f'static/js/safe_app_school/{str(current_user.id)}mapbasics.js'
|
||||||
|
t = Timer(15, remove_java, args=None, kwargs=None)
|
||||||
t.start()
|
t.start()
|
||||||
if point == 'home':
|
if point == 'home':
|
||||||
return render_template('safe_app_school/route.html', title='Маршрут домой', route='домой')
|
return render_template('safe_app_school/route.html', title='Маршрут домой', route='домой',
|
||||||
|
path=help_arg)
|
||||||
elif point == 'school':
|
elif point == 'school':
|
||||||
return render_template('safe_app_school/route.html', title='Маршрут в школу', route='в школу')
|
return render_template('safe_app_school/route.html', title='Маршрут в школу', route='в школу',
|
||||||
|
path=help_arg)
|
||||||
else:
|
else:
|
||||||
return redirect('/safe_app_school/main')
|
return redirect('/safe_app_school/main')
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -43,4 +43,7 @@
|
|||||||
.header_button_text {
|
.header_button_text {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
margin-bottom: 10%;
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@
|
|||||||
-->
|
-->
|
||||||
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU&apikey=d101001e-49f5-4a17-ac39-2d67f64b3f9b"
|
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU&apikey=d101001e-49f5-4a17-ac39-2d67f64b3f9b"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script src="../../static/js/safe_app_school/mapbasics.js" type="text/javascript"></script>
|
<script src="../../{{path}}" type="text/javascript"></script>
|
||||||
<style>
|
<style>
|
||||||
html, body, #map {
|
html, body, #map {
|
||||||
width: 100%; height: 100%; padding: 0; margin: 0;
|
width: 100%; height: 100%; padding: 0; margin: 0;
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
<div class="header">
|
<div class="header">
|
||||||
<h2 class="header_title">Пора {{ route }}</h2>
|
<h2 class="header_title">Пора {{ route }}</h2>
|
||||||
</div>
|
</div>
|
||||||
<div id="map" style="width: 70%; height: 100%; margin-left: 15%; margin-right: 15%;"></div>
|
<div id="map" style="width: 90%; height: 90%; margin-left: 5%; margin-right: 5%;"></div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h2 class="header_title">Вы не указали точки маршрута в настройках!</h2>
|
<h2 class="header_title">Вы не указали точки маршрута в настройках!</h2>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user