Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cmt120-2
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felix Chadwick-Smith
cmt120-2
Commits
130a9582
Commit
130a9582
authored
1 year ago
by
Felix Chadwick-Smith
Browse files
Options
Downloads
Patches
Plain Diff
added new app.py
parent
fe602645
No related branches found
No related tags found
1 merge request
!6
Master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app.py
+8
-13
8 additions, 13 deletions
app.py
with
8 additions
and
13 deletions
app.py
+
8
−
13
View file @
130a9582
...
...
@@ -2,7 +2,6 @@ import os
import
secrets
from
flask
import
Flask
,
render_template
,
request
,
redirect
,
url_for
,
send_from_directory
,
abort
from
flask_sqlalchemy
import
SQLAlchemy
from
wtforms
import
StringField
,
SubmitField
app
=
Flask
(
__name__
,
static_folder
=
'
static
'
)
app
.
config
[
'
SEND_FILE_MAX_AGE_DEFAULT
'
]
=
0
...
...
@@ -16,10 +15,6 @@ class Project(db.Model):
title
=
db
.
Column
(
db
.
String
(
100
),
nullable
=
False
)
description
=
db
.
Column
(
db
.
Text
,
nullable
=
False
)
class
AddProjectForm
():
# Remove FlaskForm-related code
pass
@app.route
(
'
/
'
)
def
home
():
try
:
...
...
@@ -51,21 +46,23 @@ def portfolio():
def
contact
():
return
render_template
(
'
contact.html
'
)
# Updated route for adding a project with Flask-WTF form
# Updated route for adding a project with
out
Flask-WTF form
@app.route
(
'
/add_project
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
def
add_project
():
form
=
AddProjectForm
()
if
request
.
method
==
'
POST
'
:
# Retrieve form data directly from request
title
=
request
.
form
.
get
(
'
title
'
)
description
=
request
.
form
.
get
(
'
description
'
)
if
form
.
validate_on_submit
():
# Print or log the form data to check if it's received
print
(
f
"
Received form data - Title:
{
form
.
title
.
data
}
, Description:
{
form
.
description
.
data
}
"
)
print
(
f
"
Received form data - Title:
{
title
}
, Description:
{
description
}
"
)
new_project
=
Project
(
title
=
form
.
title
.
data
,
description
=
form
.
description
.
data
)
new_project
=
Project
(
title
=
title
,
description
=
description
)
db
.
session
.
add
(
new_project
)
db
.
session
.
commit
()
return
redirect
(
url_for
(
'
home
'
))
return
render_template
(
'
add_project.html
'
,
form
=
form
)
return
render_template
(
'
add_project.html
'
)
# Updated route for serving the 'my-cv.docx' file
@app.route
(
'
/download_cv
'
)
...
...
@@ -89,5 +86,3 @@ def download_assessment(filename):
app
.
logger
.
exception
(
f
"
Error serving assessment file:
{
str
(
e
)
}
"
)
abort
(
500
)
if
__name__
==
'
__main__
'
:
app
.
run
(
debug
=
True
,
port
=
int
(
os
.
environ
.
get
(
'
PORT
'
,
5000
)))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment