远程部署的appengine-go静态文件出现404错误,而本地部署正常运行。

huangapple go评论67阅读模式
英文:

404 error on remote appengine-go static file while local deploy works

问题

我面临一个问题,即静态文件在本地机器上通过dev_appserver.py正确显示,但一旦上传到服务器上,它就不显示并给出404错误。

部分目录文件结构如下:

- static/
    articles.html
    images/*.png

部分app.yaml文件如下:

runtime: go
api_version: go1

- url: /(articles\.html)
  static_files: static/
  upload: static/*.html

然后我通过http url appname.appspot.com/articles.html访问它。

我在将其放在appengine服务器上后下载了代码,以确保articles.html实际上已经上传到所述目录中,确实如此。因此,本地和服务器上的文件结构完全相同,但服务器上会出现404错误,而本地可以正常工作。我使用的是最新版本的appengine。有关我可能做错了什么的任何帮助?

提前感谢

Sathish

英文:

I'm facing a problem where a static file is showing up correctly on the local machine via dev_appserver.py but once uploaded to the server it doesn't show and gives me a 404 error.

The partial directory file structre is:

- static/
    articles.html
    images/*.png

The partial app.yaml file is:

runtime: go
api_version: go1

- url: /(articles\.html)
  static_files: static/
  upload: static/*.html

I then to access this via the http url appname.appspot.com/articles.html.

I downloaded the code after I put it on the appengine server to ensure that articles.html has actually been uploaded in the said directory, and it has. So the exact same file structre locally and on the server, but it gives a 404 on the server and works locally. I have the latest versions of the appengine. Any help on what I could be doing wrong?

thanks in advance

Sathish

答案1

得分: 1

只是为了完整性而放上来...我回过头来尝试了各种合理的组合,发现这个配置可以工作:

- url: /(articles)\.html
  static_files: static/.html
  upload: static/.*.html

现在我声称这是荒谬的,但我记得之前尝试过为"upload"条目使用正则表达式,但它没有起作用。所以,我不清楚问题出在哪里,但我最好的猜测是dev_appserver.py可能会采取一些捷径来提供静态文件,并且不完全像appengine那样运行。我将提出这个问题,看看是否有任何解决方案或澄清。

英文:

Just putting this up for completeness ... I went back and tried various reasonable combinations again and found that this config works:

- url: /(articles)\.html
  static_files: static/.html
  upload: static/.*.html

It is ridiculous of me to make the claim now, but I remember attempting a regex for the "upload" entry earlier and it hadn't worked. So, I don't clearly know the issue, however, my best guess is that dev_appserver.py is probably taking some shortcuts to serve static files and not behaving exactly like the appengine would. I shall raise an issue on that and see if there is any resolution or clarification.

huangapple
  • 本文由 发表于 2012年7月8日 23:45:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/11384426.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定