uwsgi和bottle中存在一个文件,但是出现404错误

A file exists in uwsgi and bottle, but a 404 error occurs

文件组织

・/hoge/1/a/bottle.py ・/hoge/1/a/hoge.py ・/hoge/1/a/hoge.ini


/hoge/1/a.py 屏幕显示错误 显示内容

   Error: 404 Not Found
    Sorry, the requested URL 'http://example.com/hoge/1/a.py' caused an error:

    Not found: '/hoge/1/a.py'

/hoge/1/a.py

#!/usr/bin/python3.6 python
# -*- coding:utf-8 -*-
from bottle import route, run, default_app

@route('/')
def index():
    return "Hello World!"

application = default_app()

/hoge/1/a.ini

[uwsgi]
uid = nginx
gid = nginx
socket = /var/run/uwsgi/app/%n.sock
chmod-socket = 777
chdir = /var/www/example.com/hoge/1
wsgi-file = /var/www/example.com/hoge/1/%n.py
file         = %n.py
processes = 4
threads = 2

a.ini 日志

announcing my loyalty to the Emperor...

这是因为 bottle 仅提供与为其设置的 @route 之一相匹配的 URL。在这种情况下,设置的唯一路由是 /,因此只有 http://example.com/ 有效。