Skip to content

Commit f46c0ad

Browse files
committed
fixed minor bugs
1 parent 29f502f commit f46c0ad

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

educative-viewer.py

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -114,31 +114,35 @@ def clear():
114114

115115

116116
if __name__ == "__main__":
117-
118-
while True:
119-
clear()
120-
print('''
121-
Educative viewer, made by Anilabha Datta
122-
Project Link: https://github.com/anilabhadatta/educative-viewer
123-
Read the documentation for more information about this project.
124-
125-
-> Enter Course path to start the server
126-
-> Leave Blank and press Enter to exit
127-
''')
128-
get_ip()
129-
course_directory = input("User Input: ")
130-
if course_directory == '':
131-
break
132-
elif os.path.isdir(course_directory):
133-
itr = 0
134-
my_loader = jinja2.ChoiceLoader([
135-
app.jinja_loader,
136-
jinja2.FileSystemLoader([f'{ROOT_DIR}/templates',
137-
f'{course_directory}']),
138-
])
139-
app.jinja_loader = my_loader
140-
print(f"For Mobile/Desktop view use {ip_address}:{port}")
141-
app.run(host="0.0.0.0", threaded=True, port=port)
142-
else:
143-
print("Invalid path")
144-
input("Press enter to continue")
117+
try:
118+
while True:
119+
clear()
120+
print('''
121+
Educative viewer, made by Anilabha Datta
122+
Project Link: https://github.com/anilabhadatta/educative-viewer
123+
Read the documentation for more information about this project.
124+
125+
-> Enter Course path to start the server
126+
-> Leave Blank and press Enter to exit
127+
''')
128+
get_ip()
129+
course_directory = input("User Input: ")
130+
if course_directory == '':
131+
break
132+
elif os.path.isdir(course_directory):
133+
itr = 0
134+
my_loader = jinja2.ChoiceLoader([
135+
app.jinja_loader,
136+
jinja2.FileSystemLoader([f'{ROOT_DIR}/templates',
137+
f'{course_directory}']),
138+
])
139+
app.jinja_loader = my_loader
140+
print(f"For Mobile/Desktop view use {ip_address}:{port}")
141+
app.run(host="0.0.0.0", threaded=True, port=port)
142+
else:
143+
print("Invalid path")
144+
input("Press enter to continue")
145+
except KeyboardInterrupt:
146+
print("Exited")
147+
except Exception as e:
148+
print("Exited")

0 commit comments

Comments
 (0)