小编use*_*873的帖子

带有多个文件的瓶子框架

我已经阅读了瓶文档,但是我找不到如何使用Bottle和多个文件的示例.下面是我做的方式,它的工作,但我不知道这是否是去(我看到的正确方法merge(),并mount()在API,但不知道他们都与此有关).请给我评论.

  1. all.py(这是运行的主文件)

    #! /usr/bin/python
    from bottle import route, run
    
    import hello1
    import hello2    # if I have 10 files, it will be 10 imports
    
    run(host='localhost', port=8080, debug=True)
    
    Run Code Online (Sandbox Code Playgroud)
  2. hello1.py

    #! /usr/bin/python
    from bottle import route, run
    
    @route('/hello1')
    def hello1():
        return "Hello world no.1"
    
    Run Code Online (Sandbox Code Playgroud)
  3. hello2.py

    #! /usr/bin/python
    from bottle import route, run
    
    @route('/hello2')
    def hello2():
        return "Hello world no.2"
    
    Run Code Online (Sandbox Code Playgroud)

python frameworks bottle

12
推荐指数
2
解决办法
6372
查看次数

标签 统计

bottle ×1

frameworks ×1

python ×1