mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 04:12:45 +00:00 
			
		
		
		
	Add 503 error handler
This commit is contained in:
		@@ -40,3 +40,13 @@ def internal_server_error(e):
 | 
				
			|||||||
        response.status_code = 500
 | 
					        response.status_code = 500
 | 
				
			||||||
        return response
 | 
					        return response
 | 
				
			||||||
    return render_template('errors/500.html.j2', title='Internal Server Error'), 500
 | 
					    return render_template('errors/500.html.j2', title='Internal Server Error'), 500
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@bp.app_errorhandler(503)
 | 
				
			||||||
 | 
					def service_unavailable_error(e):
 | 
				
			||||||
 | 
					    if (request.accept_mimetypes.accept_json
 | 
				
			||||||
 | 
					            and not request.accept_mimetypes.accept_html):
 | 
				
			||||||
 | 
					        response = jsonify({'error': 'service unavailable'})
 | 
				
			||||||
 | 
					        response.status_code = 503
 | 
				
			||||||
 | 
					        return response
 | 
				
			||||||
 | 
					    return render_template('errors/503.html.j2', title='Service Unavailable'), 503
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										19
									
								
								app/templates/errors/503.html.j2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								app/templates/errors/503.html.j2
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					{% extends "base.html.j2" %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% block page_content %}
 | 
				
			||||||
 | 
					<div class="container">
 | 
				
			||||||
 | 
					  <h1 id="title">{{ title }}</h1>
 | 
				
			||||||
 | 
					  <p class="light">{{ request.path }}</p>
 | 
				
			||||||
 | 
					  <p>Alternatively, you can visit the <a href="{{ url_for('main.index') }}">Main Page</a> or read <a class="modal-trigger" href="#more-information-modal">more information</a> about this type of error.</p>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="modal" id="more-information-modal">
 | 
				
			||||||
 | 
					  <div class="modal-content">
 | 
				
			||||||
 | 
					    <h2>About the "{{ title }}" error</h2>
 | 
				
			||||||
 | 
					    <p>The server cannot handle the request (because it is overloaded or down for maintenance). Generally, this is a temporary state.</p>
 | 
				
			||||||
 | 
					  </div>
 | 
				
			||||||
 | 
					  <div class="modal-footer">
 | 
				
			||||||
 | 
					    <a href="#!" class="btn-flat modal-close waves-effect waves-green">Close</a>
 | 
				
			||||||
 | 
					  </div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					{% endblock page_content %}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user