Personal website in Flask

by: johnsimmons, 9 years ago


Hello fellow python programmers. I recently completed the Flask tutorials here and made a personal website running on Flask. Any feedback welcome. Thanks

http://www.john-simmons.net
https://github.com/johndavidsimmons/jsnet



You must be logged in to post. Please login or register an account.



Awesome! Thanks for sharing it here. I don't have much to add, your 404 page is missing css.

Curious where you got the idea to do try/except: return 500.html? I'll sometimes return str(e) when testing and developing, but that's definitely not the ideal in production.

Instead of that, I would recommend you have the following, much like your 404 handling:

@app.errorhandler(500)
def error_500(e):
    return render_template('your500template.html')


Also, I would not suggest you get in the habit of returning str(e) from the error on a production site. I do it while debugging, and often forget to stop doing it. For hackers, being able to see the errors is a major help to figuring out what to do next. Instead, you may want to start up a log file that contains things like 404s, and 500s that people come into contact with.

Finally,
@app.route('/projects')


means the user can only go to literally /projects. If they do /projects/, it will result in a 404. For that reason I tend to end with a forward slash. Chances are, it wont be a big deal most of the time, but sometimes I am manually typing a url and include the ending slash. If that gave me a 404, before programming, I would have not tried without the slash. If you make your urls:
@app.route('/projects/')

...someone will be successful regardless of whether or not the end with the slash.

Your design is really nice, much better than anything I can come up with! I would also suggest you include the actual website itself as one of your "projects."




-Harrison 9 years ago
Last edited 9 years ago

You must be logged in to post. Please login or register an account.


Thanks! I will definitely change the way I'm handling errors and add those slashes. Weird thing about my 404 page, something funky is going on with the CSS and JS. It should having all the styling of the rest of the pages, but the console is showing

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://www.john-simmons.net/resume/static/bootstrap.min.css".


This looks similar:
http://stackoverflow.com/questions/3467404/chrome-says-resource-interpreted-as-script-but-transferred-with-mime-type-text

-johnsimmons 9 years ago
Last edited 9 years ago

You must be logged in to post. Please login or register an account.


Fixed it. My directories are all written like 'static/style.css', but when adding the ending slash to the route, directories need to be '/static/style.css' with the leading slash

-johnsimmons 9 years ago

You must be logged in to post. Please login or register an account.


Ah! I poked around briefly and that didn't jump out at me, I'll have to remember that one. Never made that error, but I couldn't figure out why yours was doing that either, even after glancing at your source on github. That's a tricky one!

-Harrison 9 years ago

You must be logged in to post. Please login or register an account.