[Python] Create a minimal website in Python using the Flask Microframework

How to install Flask Use Flask to create a minimal website Build routes in Flask to respond to website endpoints Use Variable Rules to pass parts of the URL to your functions as keyword parameters

Install:

pip install Flask

 

Development Mode:

run_local.sh:

#!/bin/bash

export FLASK_APP=app.py
export FLASK_DEBUG=1
flask run

 

app.py:

复制代码
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello world!'

@app.route('/foo/')
def foo():
    return 'The foo page'

@app.route('/bar')
def bar():
    return 'The bar page'

@app.route('/hello/')
@app.route('/hello/<name>')
def say_hello(name=None):
    return 'Hello {}'.format(user)
复制代码

 

posted @   Zhentiw  阅读(200)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2017-04-30 [Angular Unit Testing] Shallow Pipe Testing
2017-04-30 [Angular Unit Testing] Testing Pipe
点击右上角即可分享
微信分享提示