diff --git a/initapp.py b/initapp.py new file mode 100644 index 0000000..f4f0ce7 --- /dev/null +++ b/initapp.py @@ -0,0 +1,37 @@ +import subprocess +from typing import List, Tuple, Union + +def execute_command(command: str) -> Tuple[bool, Union[str, str]]: + try: + # Execute the command and capture standard output and errors + process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + stdout, stderr = process.communicate() + + # Check if there were errors during execution + if process.returncode == 0: + # Success: the command ran without errors + return True, stdout + else: + # Error: the command returned a non-zero exit code + return False, stderr + except Exception as e: + # Error during command execution + return False, str(e) + +def execute_commands(commands: List[str]) -> List[Tuple[bool, Union[str, str]]]: + results = [] + for i, command in enumerate(commands, start=1): + success, result = execute_command(command) + results.append((success, result)) + status = 'executed successfully' if success else 'error during command execution' + print(f"Command '{command}': {status}") + print(result) + + return results + +# Example of usage +commands = [ + "git add .", + "git commit -m deco" + ] +results = execute_commands(commands) diff --git a/main.py b/main.py index dd4e781..97d6bb8 100644 --- a/main.py +++ b/main.py @@ -1,43 +1,44 @@ from fastapi import FastAPI from fastapi.responses import HTMLResponse -from config.database import engine, Base -from middlewares.error_handler import ErrorHandler -from routers.movie import movie_router -from routers.user import user_router +# from config.database import engine, Base +# from middlewares.error_handler import ErrorHandler +# from routers.movie import movie_router +# from routers.user import user_router app = FastAPI() app.title = "Mi aplicación con FastAPI" app.version = "0.0.1" -app.add_middleware(ErrorHandler) +# app.add_middleware(ErrorHandler) -app.include_router(movie_router) -app.include_router(user_router) +# app.include_router(movie_router) +# app.include_router(user_router) -Base.metadata.create_all(bind=engine) +# Base.metadata.create_all(bind=engine) -movies = [ - { - "id": 1, - "title": "Avatar", - "overview": "En un exuberante planeta llamado Pandora viven los Na'vi, seres que ...", - "year": "2009", - "rating": 7.8, - "category": "Acción" - }, - { - "id": 2, - "title": "Avatar", - "overview": "En un exuberante planeta llamado Pandora viven los Na'vi, seres que ...", - "year": "2009", - "rating": 7.8, - "category": "Acción" - } -] +# movies = [ +# { +# "id": 1, +# "title": "Avatar", +# "overview": "En un exuberante planeta llamado Pandora viven los Na'vi, seres que ...", +# "year": "2009", +# "rating": 7.8, +# "category": "Acción" +# }, +# { +# "id": 2, +# "title": "Avatar", +# "overview": "En un exuberante planeta llamado Pandora viven los Na'vi, seres que ...", +# "year": "2009", +# "rating": 7.8, +# "category": "Acción" +# } +# ] @app.get('/', tags=['home']) def message(): return HTMLResponse('

Hello world

') +#holita \ No newline at end of file diff --git a/passenger_wsgi.py b/passenger_wsgi.py new file mode 100644 index 0000000..69d4145 --- /dev/null +++ b/passenger_wsgi.py @@ -0,0 +1,4 @@ +from a2wsgi import ASGIMiddleware +from main import app + +application = ASGIMiddleware(app) \ No newline at end of file diff --git a/requiremets.txt b/requiremets.txt index 303d920..d27e847 100644 Binary files a/requiremets.txt and b/requiremets.txt differ