简单的flask小程序

from flask import Flask# 创建flask应用的对象# app = Flask(__name__) #flask以这个模块所对应的目录为总目录,默认这个目录中的static为静态目录,templates为模板目录app = Flask(__name__, static_url_path="/python", #访问静态资源的url前缀,默认值是static static_folder="static", #静态文件的目录,默认是static template_folder="templates") #模板文件的目录,默认是templates# 配置参数的几种方式 见博客# 视图函数@app.route("/index<int:ids>") #默认是get请求方式,methods = ["POST","GET"]def index(ids): #<int:ids>是路由参数,视图函数中必须接收 int是转换器,可以自定义转换器
   print(ids) return "hello flask "if __name__ == __main__: # 启动flask程序 app.run(debug = True) #debug = True程序是测试模式

 

相关文章