mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
[+] New blueprint method
[+] Allows subdomain filtering for routes [+] Allows routes scalability Signed-off-by: Charles Le Maux <charles.le-maux@epitech.eu>
This commit is contained in:
parent
ef6bc53269
commit
742439be9e
@ -100,7 +100,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
|
||||
function sendRequest(endpoint, payload) {
|
||||
return fetch(`http://192.168.1.94:3000/${endpoint}`, {
|
||||
return fetch(`http://api.servii.fr:3000/${endpoint}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
10
app.py
10
app.py
@ -1,7 +1,7 @@
|
||||
import http
|
||||
import inspect
|
||||
|
||||
from flask import Flask, Response, jsonify, request
|
||||
from flask import Blueprint, Flask, Response, jsonify, request
|
||||
from flask_cors import CORS
|
||||
|
||||
import firebase_manager
|
||||
@ -10,6 +10,7 @@ import generic_executor
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
cors = CORS(app, origins=['*'])
|
||||
apiBP = Blueprint('api', 'api', subdomain="api")
|
||||
|
||||
|
||||
def generic_response_maker(status_code: http.HTTPStatus, _message: str = None) -> tuple[Response, int]:
|
||||
@ -90,7 +91,7 @@ route_handlers = {
|
||||
}
|
||||
|
||||
|
||||
@app.route('/<path:path>', methods=['POST'])
|
||||
@apiBP.route('/<path:path>', methods=['POST'])
|
||||
def dynamic_route_handler(path):
|
||||
if path not in route_handlers:
|
||||
return generic_response_maker(http.HTTPStatus.METHOD_NOT_ALLOWED)
|
||||
@ -113,5 +114,6 @@ def dynamic_route_handler(path):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
ssl_context = ('/fullchain.pem', '/privkey.pem')
|
||||
app.run(host='0.0.0.0', port=3000, debug=False)
|
||||
ssl_context = ('/secrets/fullchain.pem', '/secrets/privkey.pem')
|
||||
app.register_blueprint(apiBP)
|
||||
app.run(host='0.0.0.0', port=3000, debug=False, ssl_context=ssl_context)
|
||||
|
Loading…
Reference in New Issue
Block a user