/
Odisseywolf
/
BioSphere
Обзор
Документация
Войти
/
Odisseywolf
/
BioSphere
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
server/main.py
46 строк
1 KB
Odisseywolf
create: LICENSE, install.bat , install.sh , main.py, README.md, requirements.txt, main.py, auth.py, simulation.py, actions.py, database.py, models.py, config.py
27 май 2026, 16:28
Верифицирован
27 май 2026, 16:28
d6b5588
Код
Авторство
О чём код?
# FILE: server/main.py from fastapi import FastAPI, Depends, HTTPException from fastapi.middleware.cors import CORSMiddleware from sqlalchemy.orm import Session from database import SessionLocal, engine from models import Base import config # Создание таблиц Base.metadata.create_all(bind=engine) app = FastAPI(title="BioSphere API", version="1.0") # CORS app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Зависимость def get_db(): db = SessionLocal() try: yield db finally: db.close() # Подключение роутеров from api.simulation import router as sim_router from api.species import router as species_router from api.actions import router as actions_router from api.achievements import router as achievements_router from auth import router as auth_router app.include_router(auth_router, prefix="/auth", tags=["auth"]) app.include_router(sim_router, prefix="/api/sim", tags=["simulation"]) app.include_router(species_router, prefix="/api/species", tags=["species"]) app.include_router(actions_router, prefix="/api/action", tags=["actions"]) app.include_router(achievements_router, prefix="/api/achievements", tags=["achievements"]) @app.get("/") def root(): return {"message": "Welcome to BioSphere Server", "version": "1.0"}