mirror of
https://github.com/donlon/cloudflare-error-page.git
synced 2025-12-24 17:29:16 +00:00
editor/web: show status code from params
This commit is contained in:
@@ -6,8 +6,9 @@ const port = 3000;
|
||||
|
||||
// Define a route for GET requests to the root URL
|
||||
<%# TODO: format to JS-style object (key w/o parens) _%>
|
||||
<% const errorCode = params.error_code || 500 _%>
|
||||
app.get('/', (req, res) => {
|
||||
res.status(500).send(render_cf_error_page(<%-JSON.stringify(params, null, 2).replaceAll('\n', '\n ')%>));
|
||||
res.status(<%= /\d{3}/.test(errorCode + '') ? errorCode : 500 %>).send(render_cf_error_page(<%-JSON.stringify(params, null, 2).replaceAll('\n', '\n ')%>));
|
||||
});
|
||||
|
||||
// Start the server and listen on the specified port
|
||||
|
||||
@@ -13,6 +13,8 @@ const paramsArg = JSON.stringify(params, (key, value) => {
|
||||
.replace(`"${randomKey}true"`, 'True')
|
||||
.replace(`"${randomKey}false"`, 'False')
|
||||
.replace(`"${randomKey}null"`, 'None')
|
||||
|
||||
const errorCode = params.error_code || 500
|
||||
_%>
|
||||
from flask import Flask
|
||||
from cloudflare_error_page import render as render_cf_error_page
|
||||
@@ -23,7 +25,7 @@ app = Flask(__name__)
|
||||
@app.route('/')
|
||||
def index():
|
||||
# Render the error page
|
||||
return render_cf_error_page(<%- paramsArg.replaceAll('\n', '\n ') %>), 500
|
||||
return render_cf_error_page(<%- paramsArg.replaceAll('\n', '\n ') %>), <%= /\d{3}/.test(errorCode + '') ? errorCode : 500 %>
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, port=5000)
|
||||
|
||||
Reference in New Issue
Block a user