backend: implement users methods according to frontend

This commit is contained in:
tylen
2025-10-31 17:29:33 +02:00
parent 92c76d7155
commit 3f074e895d
5 changed files with 113 additions and 269 deletions

View File

@@ -6,27 +6,21 @@ server.py is the main source file for the Dungeon's backend service.
'''
from flask import Flask, request, jsonify
from flask_cors import CORS
from dotenv import load_dotenv
from db_client import DBClient
from car import registerCarEndpoints
from user import registerUserEndpoints
from suggestions import registerSuggestionsEndpoints
load_dotenv()
app = Flask(__name__)
app.config['JSON_AS_ASCII'] = False # Ensures non-ASCII characters are preserved
allowed_origins = [
"https://nyipyatki.davydovcloud.com",
"https://nyipyatki-dev.davydovcloud.com",
]
CORS(app, resources={r"*": {"origins": allowed_origins}}) # Only allow example.com
database = DBClient()
registerCarEndpoints(app=app, database=database)
registerUserEndpoints(app=app, database=database)
registerSuggestionsEndpoints(app=app, database=database)
@app.route('/login', methods=['POST'])
def login():
if request.is_json:
return jsonify({"hello": "user"}), 200
else:
return jsonify({'error': 'Request must contain JSON data'}), 400
if __name__ == "__main__":
app.run(debug=True)