30 lines
864 B
Python
30 lines
864 B
Python
#!/usr/bin/env python
|
|
# encoding: utf-8
|
|
|
|
'''
|
|
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 user import registerUserEndpoints
|
|
from hosting import registerHostingEndpoints
|
|
import logging
|
|
|
|
load_dotenv()
|
|
app = Flask(__name__)
|
|
app.config['JSON_AS_ASCII'] = False # Ensures non-ASCII characters are preserved
|
|
logging.basicConfig(level=logging.INFO)
|
|
allowed_origins = [
|
|
"https://nyipyatki.davydovcloud.com",
|
|
"http://192.168.100.*",
|
|
]
|
|
CORS(app, resources={r"*": {"origins": allowed_origins}}) # Only allow example.com
|
|
database = DBClient(app)
|
|
registerUserEndpoints(app=app, database=database)
|
|
registerHostingEndpoints(app=app, database=database)
|
|
|
|
if __name__ == "__main__":
|
|
app.run(debug=True) |