mirror of
https://github.com/asimonson1125/asimonson1125.github.io.git
synced 2026-02-25 05:09:49 -06:00
Convert React pages to Flask
oorah.
This commit is contained in:
68
src/app.py
68
src/app.py
@@ -1,19 +1,50 @@
|
||||
import flask
|
||||
from flask_minify import Minify
|
||||
import json
|
||||
|
||||
proj = json.load(open('./static/json/projects.json', 'r'))
|
||||
timeline = json.load(open('./static/json/timeline.json', 'r'))
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
Minify(app=app, html=True, js=True, cssless=True)
|
||||
|
||||
@app.route('/')
|
||||
|
||||
@app.route("/")
|
||||
def home():
|
||||
return flask.render_template('home.html', title='Andrew Simonson - Portfolio Home', description="Andrew Simonson's Digital portfolio home", canonical='')
|
||||
return flask.render_template(
|
||||
"home.html",
|
||||
title="Andrew Simonson - Portfolio Home",
|
||||
description="Andrew Simonson's Digital portfolio home",
|
||||
canonical="",
|
||||
)
|
||||
|
||||
@app.route('/about')
|
||||
|
||||
@app.route("/about")
|
||||
def about():
|
||||
return flask.render_template('about.html', title='Andrew Simonson - About Me', description="About Andrew Simonson", canonical='about')
|
||||
return flask.render_template(
|
||||
"about.html",
|
||||
timeline=timeline,
|
||||
title="Andrew Simonson - About Me",
|
||||
description="About Andrew Simonson",
|
||||
canonical="about",
|
||||
)
|
||||
|
||||
@app.route('/resume')
|
||||
@app.route('/Resume.pdf')
|
||||
|
||||
@app.route("/projects")
|
||||
def projects():
|
||||
return flask.render_template(
|
||||
"projects.html",
|
||||
projects=proj,
|
||||
title="Andrew Simonson - Projects",
|
||||
description="Recent projects by Andrew Simonson on his lovely portfolio website :)",
|
||||
canonical="projects",
|
||||
)
|
||||
|
||||
|
||||
@app.route("/resume")
|
||||
@app.route("/Resume.pdf")
|
||||
def resume():
|
||||
return flask.send_file('./static/resume.pdf')
|
||||
return flask.send_file("./static/Resume.pdf")
|
||||
|
||||
|
||||
@app.errorhandler(Exception)
|
||||
@@ -23,14 +54,25 @@ def page404(e):
|
||||
try:
|
||||
message = e.length
|
||||
finally:
|
||||
return flask.render_template('error.html', error=eCode, message=message, title=f'{eCode} - Simonson Portfolio'), eCode
|
||||
return (
|
||||
flask.render_template(
|
||||
"error.html",
|
||||
error=eCode,
|
||||
message=message,
|
||||
title=f"{eCode} - Simonson Portfolio",
|
||||
),
|
||||
eCode,
|
||||
)
|
||||
|
||||
@app.route('/sitemap.xml')
|
||||
@app.route('/robots.txt')
|
||||
|
||||
@app.route("/sitemap.xml")
|
||||
@app.route("/robots.txt")
|
||||
def static_from_root():
|
||||
return flask.send_from_directory(app.static_folder, flask.request.path[1:])
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sass
|
||||
sass.compile(dirname=('static/scss', 'static/css'), output_style='compressed')
|
||||
app.run()
|
||||
|
||||
sass.compile(dirname=("static/scss", "static/css"), output_style="compressed")
|
||||
app.run(debug=True)
|
||||
|
||||
Reference in New Issue
Block a user