final version

This commit is contained in:
Justin Weins 2025-04-28 15:37:49 +02:00
parent 9b8171db5b
commit 17ee42c8ea
7 changed files with 37 additions and 7 deletions

View File

@ -11,6 +11,9 @@
<orderEntry type="jdk" jdkName="Python 3.12 (announcementService) (2)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PackageRequirementsSettings">
<option name="versionSpecifier" value="Strong equality (==x.y.z)" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
<option name="TEMPLATE_FOLDERS">

View File

@ -2,7 +2,7 @@
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="@localhost" uuid="5bd2f97d-04d9-4780-924c-77d00c802fc5">
<driver-ref>mongo</driver-ref>
<driver-ref>mongo.4</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.dbschema.MongoJdbcDriver</jdbc-driver>
<jdbc-url>mongodb://localhost:27017</jdbc-url>

1
app.py
View File

@ -1,4 +1,5 @@
from flask import Flask, jsonify, request
from flask_cors import cross_origin
app = Flask(__name__)

View File

@ -2,17 +2,29 @@
import logging
import connexion
from connexion.middleware import MiddlewarePosition
from flask import Flask
from openapi_server import encoder
from pymongo import MongoClient
from starlette.middleware.cors import CORSMiddleware
client = MongoClient(host='mongodb://host.docker.internal:27017/')
db = client["MainDB"]
collection = db['patch_notes']
app = connexion.App(__name__, specification_dir='./openapi/')
app.app.logger.setLevel(logging.DEBUG)
app.app.json_encoder = encoder.JSONEncoder
app = connexion.FlaskApp(__name__, specification_dir='./openapi/')
app.add_middleware(
CORSMiddleware,
position=MiddlewarePosition.BEFORE_EXCEPTION,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.add_api('openapi.yaml',
base_path='/api',
arguments={'title': 'announcementService'},

View File

@ -213,3 +213,12 @@ def patchnotes_get(): # noqa: E501
mimetype='application/json',
status=200,
)
def cors_options_handler():
from flask import make_response
response = make_response('')
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'
response.headers['Access-Control-Allow-Headers'] = 'Content-Type, Authorization'
return response

View File

@ -11,3 +11,4 @@ werkzeug == 3.1.3
swagger-ui-bundle >= 0.0.2
uvicorn >= 0.21.1
typing_extensions~=4.12.2
flask_cors >= 5.0.1

View File

@ -11,3 +11,7 @@ werkzeug == 3.1.3
swagger-ui-bundle >= 0.0.2
uvicorn >= 0.21.1
typing_extensions~=4.12.2
flask_cors >= 5.0.1
typing_extensions==4.12.2
Flask-Testing==0.8.1
starlette==0.46.1