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