doudu9094 2016-02-27 17:14
浏览 99
已采纳

部署到Web Service时,PHP页面不显示样式表或Javascript

I am new to PHP. Just to get started with things, I created a new directory and copied some CSS and JS files I've been working on and created a PHP file and coped the HTML Code in to it.

Directory:

enter image description here

Then I created a app.yaml file:

application: project-test1234323
version: 1
runtime: php55
api_version: 1

handlers:
- url: /.*
  script: feed.php

Header of the feed.php File:

<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Dashboard</title>

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="font-awesome/css/font-awesome.css" rel="stylesheet">

    <!-- Toastr style -->
    <link href="css/plugins/toastr/toastr.min.css" rel="stylesheet">

    <!-- Gritter -->
    <link href="js/plugins/gritter/jquery.gritter.css" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

</head>

I deployed this to my Google App Engine Project (using Google App Engine Launcher for WIndows) and I end up with this:

Why am I not seeing my style sheets or any of the web content for that matter. Have I configured the Directory wrong?

  • 写回答

1条回答 默认 最新

  • dongzhashou0116 2016-02-27 20:44
    关注

    That's because app engine doesn't know where to locate those files just yet. You'll need to make them known in your app.yaml's handlers section:

    You can write rules for all your static assets such as:

    - url: /css
      static_dir: css
    
    - url: /font-awesome
      static_dir: fontawesome
    
    - url: /fonts
      static_dir: fonts
    
    - url: /img
      static_dir: img
    
    - url: /js
      static_dir: js
    

    etc, etc.

    To make things easier though, you can move all your static resources into a new folder, and create a single handler to serve them all while properly referencing them in your main script

    .
    ├── app.yaml
    ├── feed.php
    └── static
        ├── css
        ├── font-awesome
        ├── fonts
        ├── img
        └── js
    

    app.yaml:

    url: /static
    static_dir: static
    

    feed.php:

    <link href="static/css/bootstrap.min.css" rel="stylesheet">
    ...
    ...
    ...
    <link href="static/js/plugins/gritter/jquery.gritter.css" rel="stylesheet">
    

    Learn more about how to configure your php appengine app to respond to request handlers and static files here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站