立即注册 登录
社友网(新版) 返回首页

admin的个人空间 http://su.sseuu.com/?1 [收藏] [复制] [分享] [RSS]

日志

2024-01-19

已有 22 次阅读2024-1-19 20:29

from wsgiref.simple_server import make_server from jinja2 import Environment, FileSystemLoader import time # 添加 time 模块,以便生成当前时间 # 创建一个 Jinja2 环境,用于加载模板 env = Environment(loader=FileSystemLoader('./templates')) # WSGI 应用程序 def app(environ, start_response): status = '200 OK' headers = [('Content-type', 'text/html')] start_response(status, headers) # 使用 Jinja2 渲染模板 template = env.get_template('index.html') current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # 获取当前时间并格式化 rendered_template = template.render(current_time=current_time) return [rendered_template.encode()] if __name__ == '__main__': with make_server('', 3000, app) as httpd: print("Serving on port 3000...") httpd.serve_forever()

-------------------------------
from wsgiref.simple_server import make_server
from jinja2 import Environment, FileSystemLoader
import time # 添加 time 模块,以便生成当前时间
# 创建一个 Jinja2 环境,用于加载模板
env = Environment(loader=FileSystemLoader('./templates'))
# WSGI 应用程序
def app(environ, start_response):
status = '200 OK'
headers = [('Content-type', 'text/html')]
start_response(status, headers)
# 使用 Jinja2 渲染模板
template = env.get_template('index.html')
current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # 获取当前时间并格式化
rendered_template = template.render(current_time=current_time)
return [rendered_template.encode()]
if __name__ == '__main__':
with make_server('', 3000, app) as httpd:
print("Serving on port 3000...")
httpd.serve_forever()

全部作者的其他最新日志

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 立即注册

小黑屋|Archiver|手机版|su.sseuu.com ( 粤ICP备12005776号

GMT+8, 2024-5-15 13:53 , Processed in 0.033396 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2013 Comsenz Inc.

返回顶部