Skip to content
Snippets Groups Projects
Commit b82a4c7b authored by Felix Chadwick-Smith's avatar Felix Chadwick-Smith
Browse files

Merge branch 'master' into 'main'

added refferences

See merge request !29
parents 7121d0c1 09445d2d
No related branches found
No related tags found
1 merge request!29added refferences
No preview for this file type
File deleted
No preview for this file type
#https://users.cs.cf.ac.uk/MoloughneyMJ/FlaskReference/FlaskCribSheets very helpful for setting it up for the first time
#https://realpython.com/flask-project/#create-a-virtual-environment - showed me how to expand on inital setup
import os
import secrets
from flask import Flask, render_template, request, redirect, flash
#https://flask.palletsprojects.com/en/3.0.x/quickstart/#a-minimal-application for inital flask set up
from flask import Flask, render_template, request, redirect, url_for, send_from_directory, abort, current_app
from flask_sqlalchemy import SQLAlchemy
from flask_wtf import FlaskForm
......@@ -10,6 +13,8 @@ from wtforms.validators import DataRequired
app = Flask(__name__, static_folder='static')
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
#https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-iv-database
#https://realpython.com/flask-by-example-part-2-postgres-sqlalchemy-and-alembic/
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.abspath(os.path.join(os.path.dirname(__file__), 'instance/site.db'))
app.config['SECRET_KEY'] = secrets.token_hex(16)
......@@ -24,6 +29,7 @@ class ProjectForm(FlaskForm):
title = StringField('Title', validators=[DataRequired()])
description = TextAreaField('Description', validators=[DataRequired()])
submit = SubmitField('Add Project')
#https://flask.palletsprojects.com/en/3.0.x/quickstart/#a-minimal-application - Routes for developing my routes for each page
@app.route('/')
def home():
......@@ -75,6 +81,7 @@ def add_project():
return render_template('add_project.html', form=form)
# Updated route for serving the 'my-cv.docx' file
@app.route('/download_cv')
#https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xx-some-javascript-magic
def download_cv():
file_path = 'static/my-cv.docx'
print(f"Attempting to serve file: {file_path}")
......@@ -99,4 +106,5 @@ def download_assessment(filename):
if __name__ == '__main__':
with app.app_context():
db.create_all()
#https://flask.palletsprojects.com/en/3.0.x/quickstart/#a-minimal-application for learning how to debug
app.run(debug=False, port=int(os.environ.get('PORT', 8080)))
\ No newline at end of file
......@@ -16,6 +16,7 @@
</head>
<body class="home-page">
<!---https://realpython.com/flask-project/#create-a-virtual-environment--->
<nav>
<ul>
<li><a href="{{ url_for('home') }}">Home</a></li>
......@@ -27,6 +28,7 @@
</ul>
</nav>
<h2>Add Project</h2>
<!---https://realpython.com/flask-project/#create-a-virtual-environment--->
<form method="POST" action="{{ url_for('add_project') }}">
{% with messages = get_flashed_messages() %}
{% if messages %}
......@@ -36,7 +38,7 @@
{% endfor %}
</ul>
{% endif %}
{% endwith %}
{% endwith %}
{% if form %}
{{ form.csrf_token }}
<div class="form-group">
......
<!---https://css-tricks.com/crafting-reusable-html-templates/-->
<!DOCTYPE html>
<html lang="en">
<head>
......
work-1.png

889 KiB

work-3.png

706 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment