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

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

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line