感谢您的反馈!
from flask import Flask,render_template app = Flask(__name__) @app.route('/hello') def hello_world(): return 'Hello World!' @app.route('/') def index(): return render_template('index.html') @app.route('/hello/<name>') def hello(name): return render_template('index.html',name=name)
<html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta charset="utf-8"> </head> <title>Hello from Flask</title> {% if name %} <h1>Hello {{ name }}!</h1> {% else %} <h1>Hello World!</h1> {% endif %} </html>
init: /myapp.py framework: flask
import web render = web.template.render('templates/') urls = ( '/(.*)', 'index' ) class index: def GET(self, name): return render.index(name)
$def with (name) $if name: I just wanted to say <em>hello</em> to $name. $else: <em>Hello</em>, world!
init: /myapp.py framework: web.py
from pyramid.config import Configurator from pyramid.response import Response def index(request): return Response('Hello World!') def hello_world(request): return Response('Hello %(name)s!' % request.matchdict) config = Configurator() config.add_route('index', '/') config.add_view(index, route_name='index') config.add_route('hello', '/hello/{name}') config.add_view(hello_world, route_name='hello') app = config.make_wsgi_app()
init: /myapp.py framework: pyramid
import tornado.wsgi class MainHandler(tornado.web.RequestHandler): def get(self): self.write("Hello, world") application = tornado.wsgi.WSGIApplication([ (r"/", MainHandler) ])
init: /myapp.py framework: tornado