Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

diyism/cloudflare_python_home_page

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cloudflare PHP (cloudflare Python Home Page)

https://dash.cloudflare.com/ > Workers & Pages > Create > Start from a template/Python Hello World > Edit Code

copy the code of index.py into it, and click "Deploy"

You can modify the "pyml"(html+embeded python) in the pyml variable, the python code in the "<: ... :>"(similar to "<?php ... ?>" in php):

pyml = """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hello World</title>
</head>
<body>
<:user_name="jack"
:>
    <h1>Hello, <:for i in range(2):#{#:><:=user_name:>,<:#}#:>!</h1>
    <p>Welcome to my cloudflare python home page.</p>
<:response = await fetch("http://httpx.com")
html=await response.text()
matches = re.search(r"<h2[^>]*>Your IP Address</h2>.*?<h1[^>]*>(.*?)</h1>", html, re.DOTALL)
if matches:
    ip_address = matches.group(1).strip()
    text_content = f"Cloudflare IP Address: {ip_address}<br/>"
    write.append(text_content)
else:
    write.append("IP Address not found.")
write.append("Your IP Address:"+request.headers.get("cf-connecting-ip"))
:>
</body>
</html>
"""

About

Cloudflare PHP (cloudflare Python Home Page)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.