2016-08-14 11 views
1

CSSを正しくリンクするのに問題があります。それは正しく命名されました。それは働きたくありません。私はそれを打ち込むあらゆる可能な方法を試みました。私はさまざまなことを聞​​いたことがある。あなたは、プロジェクトのURL全体(simple-login/css/style.css)を入力しなければならないと言う人もいます。私はあなたがちょうど1つ上のレベル(../css/style.css)に行かなければならないと聞いたことがあります。私はあなたもそうする必要はないと聞いてきました(css/style.css)。何も働きたくないようです。通常のHTMLファイルでは常に正常に動作します。私は何かを輸入しなければなりませんか?私は本当に不満を感じています。私はこのプロジェクトにCSSを直接​​埋め込むはずがありません。別のファイルにする必要があります。Python - 組み込みHTMLでCSSが動作しない

import webapp2 #Use the webapp2 Library 

class MainHandler(webapp2.RequestHandler): #declaring a class 
    def get(self): 
     if self.request.GET: #variables that store the information from the forms. This information will be used in the write() method to put the information on the page. Parts of the html, stored in variables, are strung together in the write() method. 
      user = self.request.GET['user'] 
      email = self.request.GET['email'] 
      games = self.request.GET['games'] 
      city = self.request.GET['city'] 
      state = self.request.GET['state'] 
      gender = self.request.GET['gender'] 
      self.response.write(Page.interface_head + Page.interface_body + Page.interface_info + Page.info_name + user + '</br>' + Page.info_email + email + '</br>' + Page.info_games + games + '</br>' + Page.info_city + city + ', ' + state + '</br>' + Page.info_gender + gender + Page.info_close + Page.interface_closing) 
     else: #This is what the write method does when there is no response to the request. Meaning this is the page you are met with in the beginning. Parts of the html, stored in variables, are strung together in the write() method. 
      self.response.write(Page.interface_head + Page.interface_body + Page.interface_forms + Page.interface_closing) 

class Page(object): 
     interface_head = '''<!Doctype HTML> <!--This houses all code in the head of my HTML including the style portion.--> 
<html> 
    <head> 
     <title>Simple Form</title> 
     <link href="css/style.css" rel="stylesheet" type="text/css"/> 
    </head> 
    <body>''' 

     interface_body = '''<nav><h2>Game<span>Stuff</span></h2></nav> <!--This is the code for the nav all the way down to the forms.-->''' 

     interface_info = '''<div class='info_background'> <!--This is the start of the div that houses the information entered from the forms. Below are all the labels split up into vriables. This is for organization and will be reassembled in the if and else statement.--> 
      <h3>Is this information correct?</h3>''' 
     info_name = '''<label>Name: </label>''' 
     info_email = '''<label>Email: </label>''' 
     info_games = '''<label>Favorite Games: </label>''' 
     info_city = '''<label>City/State: </label>''' 
     info_gender = '''<label>Gender: </label>''' 
     info_close = ''' 
     </br><button>Yes</button><button>No</button></div>''' 
     interface_forms = '''<form method='GET'><!--These forms enter the information to be stored in the variables in the if statement.--> 
      <h3>Sign Up for a free account!</h3> 
      <label>Name: </label><input type='text' name='user' /> 
      <label>Email: </label><input type='text' name='email' /></br> 
      <label>Favorite Games: </label><input type='text' name='games' /> 
      <label>City: </label><input type='text' name='city' style='width: 120px;' /> 
      <label>State: </label><select name='state'> 
      <option value="AL">Alabama</option> 
      <option value="AK">Alaska</option> 
      <option value="AZ">Arizona</option> 
      <option value="AR">Arkansas</option> 
      <option value="CA">California</option> 
      <option value="CO">Colorado</option> 
      <option value="CT">Connecticut</option> 
      <option value="DE">Delaware</option> 
      <option value="DC">District Of Columbia</option> 
      <option value="FL">Florida</option> 
      <option value="GA">Georgia</option> 
      <option value="HI">Hawaii</option> 
      <option value="ID">Idaho</option> 
      <option value="IL">Illinois</option> 
      <option value="IN">Indiana</option> 
      <option value="IA">Iowa</option> 
      <option value="KS">Kansas</option> 
      <option value="KY">Kentucky</option> 
      <option value="LA">Louisiana</option> 
      <option value="ME">Maine</option> 
      <option value="MD">Maryland</option> 
      <option value="MA">Massachusetts</option> 
      <option value="MI">Michigan</option> 
      <option value="MN">Minnesota</option> 
      <option value="MS">Mississippi</option> 
      <option value="MO">Missouri</option> 
      <option value="MT">Montana</option> 
      <option value="NE">Nebraska</option> 
      <option value="NV">Nevada</option> 
      <option value="NH">New Hampshire</option> 
      <option value="NJ">New Jersey</option> 
      <option value="NM">New Mexico</option> 
      <option value="NY">New York</option> 
      <option value="NC">North Carolina</option> 
      <option value="ND">North Dakota</option> 
      <option value="OH">Ohio</option> 
      <option value="OK">Oklahoma</option> 
      <option value="OR">Oregon</option> 
      <option value="PA">Pennsylvania</option> 
      <option value="RI">Rhode Island</option> 
      <option value="SC">South Carolina</option> 
      <option value="SD">South Dakota</option> 
      <option value="TN">Tennessee</option> 
      <option value="TX">Texas</option> 
      <option value="UT">Utah</option> 
      <option value="VT">Vermont</option> 
      <option value="VA">Virginia</option> 
      <option value="WA">Washington</option> 
      <option value="WV">West Virginia</option> 
      <option value="WI">Wisconsin</option> 
      <option value="WY">Wyoming</option> 
     </select> 
     <label>Gender: </label><input type="radio" name="gender" value="Male"> Male 
     <input type="radio" name="gender" value="Female"> Female 
     <input type="radio" name="gender" value="Other"> Other 
     <input type="submit" value='Create Account'/> <!--This submit button finalizes all the information put in the forms.--> 
     </form>''' 

     interface_closing = ''' 
      <footer>&copy;Made by Matt Lee</footer> <!--This is a footer I made just so there was something final on the page.--> 
    </body> 
</html>''' 

app = webapp2.WSGIApplication([ 
    ('/', MainHandler) 
], debug=True) 
+0

あなたのフレームワークは何ですか? WSGIアプリケーションでは、静的ファイルが提供されない可能性があります。そのためにnginxのようなものが必要かもしれません –

+0

これは、Google App Engine Launcherの通常のPythonです。フレームワークはありません。 –

+1

テンプレートを使用していないのはなぜですか? PythonでHTMLを構築するべきではありません。 –

答えて

0

Jinja 2を使用することをお勧めします。コードを整理するのに役立ちます。これはWebapp2で本当に使いやすいテンプレート言語です。

関連する問題