A mirror of my website's source code.

By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

Added a local testing server

steve0greatness,
created on Monday, 15 January 2024, 05:39:31 (1705297171), received on Monday, 6 May 2024, 02:55:34 (1714964134)
Author identity: Steve0Greatness <75220768+Steve0Greatness@users.noreply.github.com>

4938092dbdbd334126d3c04331125597a609113d

local-server.py

@@ -0,0 +1,20 @@

                                
                                
                                
                            
                                
                                    
                                        
                                        # This is a development server, it's not used on the actual site.
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        from flask import Flask, send_file as SendFile
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        from os.path import isfile
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        from pathlib import Path
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        FlaskOpts = {}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        app = Flask(__name__, **FlaskOpts)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        @app.route("/", defaults={"path": ""})
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        @app.route("/<path:path>")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        def SendStatic(path):
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            if isfile("build/" + path):
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                return SendFile(Path("build").joinpath(path))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            elif isfile(Path("build").joinpath(path, "index.html")):
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                return SendFile(Path("build").joinpath(path, "index.html"))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            return SendFile("build/404.html")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        if __name__ == "__main__":
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            app.run("0.0.0.0", 8000, debug=True)