Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDDDE27_2024_WEB_PROJECT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package 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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TDDD27_MYPET
TDDDE27_2024_WEB_PROJECT
Commits
ca1aca7f
Commit
ca1aca7f
authored
1 year ago
by
danielmyren
Browse files
Options
Downloads
Patches
Plain Diff
can now serve react build
parent
177d4d68
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
backend/app.py
+5
-1
5 additions, 1 deletion
backend/app.py
backend/routes_auth.py
+9
-3
9 additions, 3 deletions
backend/routes_auth.py
backend/routes_default.py
+12
-10
12 additions, 10 deletions
backend/routes_default.py
backend/templates/index.html
+0
-9
0 additions, 9 deletions
backend/templates/index.html
with
26 additions
and
23 deletions
backend/app.py
+
5
−
1
View file @
ca1aca7f
import
os
from
flask
import
Flask
from
flask
import
current_app
from
flask
import
render_template_string
from
flask_sqlalchemy
import
SQLAlchemy
from
config
import
Config
from
flask_security
import
Security
,
SQLAlchemyUserDatastore
,
auth_required
,
hash_password
...
...
@@ -11,6 +11,8 @@ from flask_security.models import fsqla_v3 as fsqla
app
=
Flask
(
__name__
)
app
.
config
.
from_object
(
Config
)
app
.
static_folder
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
..
'
,
'
frontend
'
,
'
build
'
,
'
static
'
))
app
.
build_folder
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
..
'
,
'
frontend
'
,
'
build
'
))
# Define security configurations:
if
not
app
.
config
[
'
DEBUG
'
]:
...
...
@@ -32,6 +34,8 @@ app.security = Security(app, user_datastore)
#login_manager.init_app(app)
"""
if
__name__
==
'
__main__
'
:
with
app
.
app_context
():
...
...
This diff is collapsed.
Click to expand it.
backend/routes_auth.py
+
9
−
3
View file @
ca1aca7f
from
flask
import
Blueprint
from
flask
import
render_template_string
from
flask_login
import
LoginManager
from
flask_security
import
auth_required
auth
=
Blueprint
(
"
auth
"
,
__name__
)
@auth.route
(
"
/login
"
)
def
login
():
pass
@auth.route
(
"
/signup
"
)
def
signup
():
pass
@auth.route
(
"
/login
"
)
def
login
():
return
render_template_string
(
"
Hello
"
)
@auth_required
()
@auth.route
(
"
/logout
"
)
def
logout
():
pass
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/routes_default.py
+
12
−
10
View file @
ca1aca7f
from
models_shared
import
db
,
User
from
flask
import
Blueprint
,
jsonify
import
os
from
flask
import
Blueprint
,
jsonify
,
send_from_directory
from
flask
import
current_app
default
=
Blueprint
(
"
default
"
,
__name__
)
@default.route
(
"
/
"
)
@default.route
(
"
/
test_user
"
)
def
test_retrieve_user
():
user
=
db
.
session
.
query
(
User
).
filter_by
(
email
=
"
test@me.com
"
).
first
()
# Check if the user exists
if
user
:
# Return user details as JSON response
return
jsonify
({
'
email
'
:
user
.
email
})
else
:
user
=
db
.
session
.
query
(
User
).
filter_by
(
email
=
"
test@me.com
"
).
first
()
if
user
.
email
!=
"
test@me.com
"
:
return
"
User not found
"
,
404
@default.route
(
'
/
'
)
def
homepage
():
print
(
current_app
.
static_folder
)
return
send_from_directory
(
current_app
.
build_folder
,
'
index.html
'
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/templates/index.html
deleted
100644 → 0
+
0
−
9
View file @
177d4d68
<!doctype html>
<html>
<head>
<title>
This is the title of the webpage!
</title>
</head>
<body>
<p>
This is an example paragraph. Anything in the
<strong>
body
</strong>
tag will appear on the page, just like this
<strong>
p
</strong>
tag and its contents.
</p>
</body>
</html>
\ 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