Skip to content
Snippets Groups Projects
Commit ca1aca7f authored by danielmyren's avatar danielmyren
Browse files

can now serve react build

parent 177d4d68
No related branches found
No related tags found
No related merge requests found
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():
......
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
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
<!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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment