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

Merge branch 'master' into 'main'

Master

See merge request !2
parents 75ed4872 40ec11dc
No related branches found
No related tags found
1 merge request!2Master
# .gitignore
# Ignore Python virtual environment
venv/
# Ignore database file
site.db
# Ignore compiled Python files
__pycache__/
*.pyc
*.pyo
*.pyd
Access token
6vJqLP1vu_gQW1YyCAFp
TXoj4fY2FNam2Liresky
\ No newline at end of file
old one: TXoj4fY2FNam2Liresky
\ No newline at end of file
gunicorn -w 4 -b 0.0.0.0:5000 wsgi:application
File added
No preview for this file type
No preview for this file type
import os
import secrets
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
from flask_sqlalchemy import SQLAlchemy
from flask import abort, jsonify
app = Flask(__name__, static_folder='static')
app = Flask('cmt120_2', static_folder='static')
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'
app.config['SECRET_KEY'] = 'your_secret_key'
# Generate a secure random key
secret_key = secrets.token_hex(16)
app.config['SECRET_KEY'] = secret_key
db = SQLAlchemy(app)
# Define the Project model
......@@ -25,7 +30,6 @@ def home():
# Handle the error, log it, or render an error template
print(f"Error fetching projects: {str(e)}")
return render_template('error.html')
@app.route('/about')
def about():
return render_template('about.html')
......@@ -66,7 +70,6 @@ def download_cv():
print(f"Attempting to serve file: {file_path}")
return send_from_directory('static', 'my-cv.docx', as_attachment=True, mimetype='application/docx')
@app.route('/download_assessment/<filename>')
def download_assessment(filename):
try:
......@@ -85,9 +88,9 @@ if __name__ == '__main__':
# Create database tables
with app.app_context():
db.create_all()
# Retrieve the assigned port or default to 5000
port = int(os.environ.get('PORT', 5000))
# Run the app
app.run(debug=True, port=port)
# Use '0.0.0.0' to allow external access
app.run(debug=True, host='0.0.0.0')
# Uncomment the following line if you're deploying on OpenShift and use port 8080
# app.run(debug=True, host='0.0.0.0', port=8080)
\ No newline at end of file
from app import app as application
import os
# Create database tables (optional)
with application.app_context():
from app import db
db.create_all()
# Retrieve the assigned port or default to 5000
port = int(os.environ.get('PORT', 5000))
from cmt120_2 import app as application
if __name__ == '__main__':
application.run(debug=True, port=port)
app = application
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment