Compare commits

..

4 commits

Author SHA1 Message Date
9f4e06d7f9 Add missing endpoints 2022-03-11 18:12:19 +01:00
8238e9555a Add HTML 2022-03-11 18:11:54 +01:00
f5fe17fa5c Add styling 2022-03-11 18:11:38 +01:00
925164e21d Add database structure 2022-03-11 18:09:49 +01:00
7 changed files with 122 additions and 2 deletions

20
app.py
View file

@ -4,8 +4,26 @@ app = Flask(__name__)
@app.route('/')
def hello_world(): # put application's code here
def home(): # put application's code here
return render_template('home.html')
@app.route('/random')
def random_image():
# TODO Implement
return NotImplementedError
@app.route('/daily')
def daily_image():
# TODO Implement
return NotImplementedError
@app.route('/all')
def all_images():
# TODO Implement
return NotImplementedError
if __name__ == '__main__':
app.run(host='0.0.0.0')

17
db/connector.py Normal file
View file

@ -0,0 +1,17 @@
import os
from sqlalchemy import create_engine
user = os.environ['DB_USER']
password = os.environ['DB_PASSWORD']
host = os.environ['DB_HOST']
port = os.environ['DB_PORT']
database = os.environ['DB_DATABASE']
def get_connection():
return create_engine(
url="mysql+pymysql://{0}:{1}@{2}:{3}/{4}".format(
user, password, host, port, database
)
)

18
db/model/image_table.py Normal file
View file

@ -0,0 +1,18 @@
import sqlalchemy as db
from db import connector
engine = connector.create_engine
metadata_obj = db.MetaData()
profile = db.Table(
'images',
metadata_obj,
db.Column('id', db.Integer, primary_key=True),
db.Column('location', db.String),
db.Column('copyright', db.String),
db.Column('date_added', db.TIMESTAMP),
)
metadata_obj.create_all(engine)

26
static/css/styles.css Normal file
View file

@ -0,0 +1,26 @@
body {
background-image: url("/random");
height: 100vh;
width: 100vw;
}
body nav {
display: flex;
flex-direction: row;
justify-content: center;
background: rgba(0, 0, 0, 0.4);
width: 100vw;
padding: 0 20px;
}
body nav ul > li {
color: white;
}
body nav ul > li :hover {
color: #13678A;
animation: ease-in;
}
body h1 {
margin: auto;
text-align: center;
}
/*# sourceMappingURL=styles.css.map */

View file

@ -0,0 +1 @@
{"version":3,"sourceRoot":"","sources":["styles.scss"],"names":[],"mappings":"AAGA;EACE;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAEA;EACE,OAnBD;EAoBC;;AAKN;EACE;EACA","file":"styles.css"}

View file

@ -0,0 +1,31 @@
// Variables
$blue: #13678A;
body {
background-image: url("/random");
height: 100vh;
width: 100vw;
nav {
display: flex;
flex-direction: row;
justify-content: center;
background: rgba(0, 0, 0, 0.4);
width: 100vw;
padding: 0 20px;
ul > li {
color: white;
:hover {
color: $blue;
animation: ease-in;
}
}
}
h1 {
margin: auto;
text-align: center;
}
}

View file

@ -3,8 +3,17 @@
<head>
<meta charset="UTF-8">
<title>DCSL Image Hosting Server</title>
<link type="text/css" href="/static/css/styles.css">
</head>
<body>
<nav>
<ul>
<li><a href="/daily">Daily Wallpaper</a></li>
<li><a href="/random">Random Wallpaper</a></li>
<li><a href="/all">All Wallpapers</a></li>
</ul>
</nav>
<h1>Welcome to the DCSL Image Hosting Server!</h1>
<h2> - Serving images since year 2022</h2>
</body>
</html>