mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-25 14:34:19 +00:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
e706a85095
4 changed files with 42 additions and 27 deletions
|
@ -5,7 +5,7 @@
|
|||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/nest_backend" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Poetry (backend)" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="Poetry (g2-progetto) (2)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -1,7 +1,6 @@
|
|||
"""
|
||||
This is the runner for the server.
|
||||
"""
|
||||
from flask import Flask
|
||||
import os
|
||||
import werkzeug.middleware.proxy_fix
|
||||
from .routes import *
|
||||
|
@ -10,27 +9,11 @@ import psycopg2
|
|||
from .gestione import *
|
||||
from flask_cors import CORS
|
||||
from flask_jwt_extended import *
|
||||
from .app import app
|
||||
|
||||
app = Flask(__name__)
|
||||
if os.getenv('COOKIE_SECRET'):
|
||||
app.secret_key = os.getenv('COOKIE_SECRET')
|
||||
else:
|
||||
app.secret_key = "testing"
|
||||
if os.getenv("JWT_SECRET_KEY"):
|
||||
app.config["JWT_SECRET_KEY"] = os.getenv("JWT_SECRET_KEY")
|
||||
else:
|
||||
app.config["JWT_SECRET_KEY"] = "testing"
|
||||
Base.init_app(app=app)
|
||||
|
||||
reverse_proxy_app = werkzeug.middleware.proxy_fix.ProxyFix(app=app, x_for=1, x_proto=0, x_host=1, x_port=0, x_prefix=0)
|
||||
if os.getenv("DATABASE_URI"):
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URI')
|
||||
else:
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:password@localhost:5432/PdSDev'
|
||||
Base.app = app
|
||||
Base.init_app(app)
|
||||
jwt = JWTManager(app)
|
||||
cors = CORS(app)
|
||||
app.config['CORS_HEADERS'] = 'Content-Type'
|
||||
# Routes setup
|
||||
|
||||
app.add_url_rule("/doa", view_func=page_doa, methods=["GET", "POST"])
|
||||
|
@ -43,7 +26,8 @@ app.add_url_rule("/api/repository/edit", view_func=page_repository_edit, methods
|
|||
app.add_url_rule("/api/repository/add_condition", view_func=page_repository_add_condition, methods=["POST"])
|
||||
|
||||
if __name__ == "__main__":
|
||||
Base.create_all()
|
||||
with app.app_context():
|
||||
Base.create_all(app=app)
|
||||
if not User.query.filter_by(isAdmin=True).all():
|
||||
Base.session.add(User(email="admin@admin.com", password=gen_password("password"), username="admin", isAdmin=True))
|
||||
Base.session.commit()
|
||||
|
|
17
code/backend/nest_backend/app.py
Normal file
17
code/backend/nest_backend/app.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from flask import Flask
|
||||
import os
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
if os.getenv('COOKIE_SECRET'):
|
||||
app.secret_key = os.getenv('COOKIE_SECRET')
|
||||
else:
|
||||
app.secret_key = "testing"
|
||||
if os.getenv("JWT_SECRET_KEY"):
|
||||
app.config["JWT_SECRET_KEY"] = os.getenv("JWT_SECRET_KEY")
|
||||
else:
|
||||
app.config["JWT_SECRET_KEY"] = "testing"
|
||||
if os.getenv("DATABASE_URI"):
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URI')
|
||||
else:
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:password@localhost:5432/PdSDev'
|
14
code/backend/nest_backend/tweet-explorer/__main__.py
Normal file
14
code/backend/nest_backend/tweet-explorer/__main__.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from nest_backend.app import app
|
||||
from nest_backend.database import *
|
||||
|
||||
Base.init_app(app=app)
|
||||
|
||||
|
||||
def start_exploring():
|
||||
pass # Codice qui
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with app.app_context():
|
||||
Base.create_all(app=app)
|
||||
start_exploring()
|
Loading…
Reference in a new issue