0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Bottle 静的ファイルに遷移するルーティングの書き方

Posted at

pyファイルの書き方

# /<filename> にアクセスしたら、accessHtml関数が呼ばれる
@route('/<filename>')
def accessHtml(filename):
    # 静的ファイルを呼び出す
    return static_file(filename, root='./')

# ↓webサーバーを起動する
if __name__ == "__main__":
    # テスト用のサーバをlocalhost:8080で起動する
    # reloader=Trueにより、ソースを書き換えると自動的に再起動される
    run(host='localhost', port=8080, reloader=True, debug=True)

htmlファイルの書き方

<a href="./移動したいファイル名">テスト</a>

参考サイト

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?