77from collections import defaultdict
88import random
99import sys
10- import subprocess
1110
1211
1312ROOT_DIR = os .path .basename (os .path .dirname (os .path .abspath (__file__ )))
@@ -79,7 +78,7 @@ def load_files(topic_directory):
7978 for root , _ , files in os .walk (os .path .join (course_directory , topic_directory )):
8079 for file in files :
8180 file_path = os .path .join (root , file )
82- if os .path .isfile (file_path ) and topic_directory not in file :
81+ if os .path .isfile (file_path ) and topic_directory not in file and ".DS_Store" not in file_path :
8382 content = "\n "
8483 try :
8584 with open (file_path , 'r' , encoding = 'utf-8' ) as f :
@@ -106,18 +105,18 @@ def topics(topics):
106105 pass
107106 if request .method == "POST" and request .form .get ("back" ) and itr > 0 :
108107 itr -= 1
109- return render_template ("topics.html" , code_present = check_code_present (topic_folders [itr ]), webpage = f"{ topic_folders [itr ]} /{ topic_folders [itr ]} .html" , folder = f"{ topic_folders [itr ]} " , url = url )
108+ return render_template ("topics.html" , code_present = check_code_present (topic_folders [itr ]), webpage = f"{ topic_folders [itr ]} /{ topic_folders [itr ]} .html" , folder = f"{ topic_folders [itr ]} " )
110109 elif request .method == "POST" and request .form .get ("forward" ) and itr < len (topic_folders )- 1 :
111110 itr += 1
112- return render_template ("topics.html" , code_present = check_code_present (topic_folders [itr ]), webpage = f"{ topic_folders [itr ]} /{ topic_folders [itr ]} .html" , folder = f"{ topic_folders [itr ]} " , url = url )
111+ return render_template ("topics.html" , code_present = check_code_present (topic_folders [itr ]), webpage = f"{ topic_folders [itr ]} /{ topic_folders [itr ]} .html" , folder = f"{ topic_folders [itr ]} " )
113112 elif request .method == 'POST' and request .form .get ("home" ):
114113 itr = 0
115114 return redirect ("/" )
116115 elif request .method == 'POST' and request .form .get ("code_filesystem" ):
117116 path = f"file:///{ course_directory } /{ topic_folders [itr ]} "
118117 path = path .replace ("\\ " , "/" )
119118 webbrowser .open (path )
120- return render_template ("topics.html" , code_present = check_code_present (topic_folders [itr ]), webpage = f"{ topic_folders [itr ]} /{ topic_folders [itr ]} .html" , folder = f"{ topic_folders [itr ]} " , url = url )
119+ return render_template ("topics.html" , code_present = check_code_present (topic_folders [itr ]), webpage = f"{ topic_folders [itr ]} /{ topic_folders [itr ]} .html" , folder = f"{ topic_folders [itr ]} " )
121120
122121
123122@app .route ("/code/<codes>" , methods = ['GET' , 'POST' ])
@@ -152,29 +151,22 @@ def initialization():
152151 Project Link: https://github.com/anilabhadatta/educative-viewer
153152 Read the documentation for more information about this project.
154153
155- -> For Cloudflared, enter the following command in a new terminal
156- cloudflared tunnel -url { ip_address } :{ port }
154+ -> For Cloudflare Tunneling, enter the following command in a new terminal
155+ For random cloudflare tunnel url : cloudflared tunnel -url { ip_address } :{ port }
156+ For custom domain tunnel url :
157+ Step 1: Modify Ip:Port in config.yml
158+ Step 2: Enter "cloudflared tunnel run" in terminal
157159 -> Leave Blank and press Enter to exit
158160 ''' )
159161
160162
161163if __name__ == "__main__" :
162164 ip_address , port = get_ip ()
163165 initialization ()
164- localhost_url = f"http://{ ip_address } :{ port } "
165- url = localhost_url
166- tunnel_url = input (
167- "Enter cloudflared tunnel url or Press Enter to skip: " )
168- if "trycloudflare.com" in tunnel_url :
169- url = tunnel_url
170166 try :
171167 while True :
172168 initialization ()
173169 course_directory = input ("Enter Course Directory Path: " )
174- if "trycloudflare.com" not in tunnel_url :
175- tunnel_url = input (
176- "Enter cloudflared tunnel url or Press Enter to skip: " )
177- url = tunnel_url
178170 if course_directory == '' :
179171 break
180172 elif os .path .isdir (course_directory ):
@@ -185,7 +177,8 @@ def initialization():
185177 f'''
186178
187179 To Open Mobile/Desktop View,
188- Tunnel Url: { tunnel_url } ,Localhost Url: { localhost_url }
180+ Tunnel Url: Use the url from cloudflare terminal window or the custom domain url
181+ Localhost Url: http://{ ip_address } :{ port }
189182
190183 ''' )
191184 app .run (host = "0.0.0.0" , threaded = True , port = port )
0 commit comments