Project 8

Folder Structure

final_project/
β”‚
β”œβ”€β”€ static/
β”‚   └── style.css
β”‚
└── app.py
final_project/ $ flask run

app.py

from flask import Flask

app = Flask(__name__)

@app.route('/')
def room1():
    return """
    <!DOCTYPE html>
    <html>
    <head>
        <link rel="stylesheet" href="/static/style.css">
        <title>Welcome to PCTI!</title>
    </head>
    <body>
        <h1>Welcome to PCTI!</h1>
        <img width="128" alt="Titlenew" src="https://upload.wikimedia.org/wikipedia/commons/7/7e/Titlenew.jpg?20120113163901">
        <p>You are in a dark hallway in the D Wing.</p>
        <LI><a href="/d202">Enter D202</a>
        <LI><a href="/d203">Enter D203</a>
    </body>
    </html>
    """

@app.route('/d202')
def d202():
    return """
    <!DOCTYPE html>
    <html>
    <head>
        <link rel="stylesheet" href="/static/style.css">
        <title>Room 2</title>
    </head>
    <body>
        <h1>D202</h1>
        <p>You see Winsel but there is something wrong with him...</p>
        <p>He's not talking about Lebron..</p>
    </body>
    </html>
    """

@app.route('/d203')
def d203():
    return """
    <!DOCTYPE html>
    <html>
    <head>
        <link rel="stylesheet" href="/static/style.css">
        <title>D203</title>
    </head>
    <body>
        <h1>Room 2</h1>
        <p>You see Brandon but there is something wrong with him...</p>
        <p>He seems more energetic than usual..</p>
        <p>Tahmid lurks in the background... waiting...</p>
    </body>
    </html>
    """

if __name__ == '__main__':
    app.run(debug=True)

static/style.css

body {
    font-family: Arial, sans-serif;
    text-align: center;
    background-color: #111;
    color: #f0f0f0;
    padding: 40px;
}

a {
    color: #00ffcc;
    font-size: 20px;
    display: inline-block;
    margin-top: 20px;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

Last updated