kopia lustrzana https://github.com/snarfed/bridgy-fed
				
				
				
			Flask routing tweak, don't redirect URLs with empty path elements
							rodzic
							
								
									40ad6a4afa
								
							
						
					
					
						commit
						a27ebc4697
					
				
							
								
								
									
										3
									
								
								app.py
								
								
								
								
							
							
						
						
									
										3
									
								
								app.py
								
								
								
								
							| 
						 | 
					@ -26,6 +26,9 @@ app.url_map.converters['regex'] = flask_util.RegexConverter
 | 
				
			||||||
app.after_request(flask_util.default_modern_headers)
 | 
					app.after_request(flask_util.default_modern_headers)
 | 
				
			||||||
app.register_error_handler(Exception, flask_util.handle_exception)
 | 
					app.register_error_handler(Exception, flask_util.handle_exception)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# don't redirect API requests with blank path elements
 | 
				
			||||||
 | 
					app.url_map.redirect_defaults = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app.wsgi_app = handlers.ndb_context_middleware(
 | 
					app.wsgi_app = handlers.ndb_context_middleware(
 | 
				
			||||||
    app.wsgi_app, client=appengine_config.ndb_client)
 | 
					    app.wsgi_app, client=appengine_config.ndb_client)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,7 +31,7 @@ CACHE_TIME = datetime.timedelta(seconds=15)
 | 
				
			||||||
@app.get(r'/r/<path:to>')
 | 
					@app.get(r'/r/<path:to>')
 | 
				
			||||||
@cache.cached(timeout=CACHE_TIME.total_seconds(), query_string=True,
 | 
					@cache.cached(timeout=CACHE_TIME.total_seconds(), query_string=True,
 | 
				
			||||||
              response_filter=flask_util.not_5xx)
 | 
					              response_filter=flask_util.not_5xx)
 | 
				
			||||||
def redir(to=None):
 | 
					def redir(to):
 | 
				
			||||||
    """301 redirect to the embedded fully qualified URL.
 | 
					    """301 redirect to the embedded fully qualified URL.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    e.g. redirects /r/https://foo.com/bar?baz to https://foo.com/bar?baz
 | 
					    e.g. redirects /r/https://foo.com/bar?baz to https://foo.com/bar?baz
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Ładowanie…
	
		Reference in New Issue