From 0dfbad63264eb68205d94d0db04c74c04168f096 Mon Sep 17 00:00:00 2001 From: brb Date: Wed, 5 Jul 2023 20:22:16 +0200 Subject: [PATCH] deleted unused code --- app.py | 45 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/app.py b/app.py index 6a2a8d6..0f38ae0 100644 --- a/app.py +++ b/app.py @@ -7,7 +7,7 @@ import logging from pydantic import BaseModel from typing import List -from utils import handle_request +from utils import clone_repository class GiteaRequest(BaseModel): ref: str @@ -25,7 +25,7 @@ app = FastAPI() @app.get('/') async def root(): - return {'message': 'Welcome to Gitea Runner'} + return '

Welcome to Gitea Runner

' @app.post('/test') async def test(request: Request): @@ -35,40 +35,17 @@ async def test(request: Request): @app.post('/event') def handle_event(request: GiteaRequest): - """ - Handle event from webhook - """ - handle_request(request) - return {'status': 'received task'} - -# @app.post('/execute') - -# @app.before_request -# def check_media_type(): -# """ -# Ignore requests that do not have Content-Type = application/json in header. -# """ -# content_type = request.headers.get('Content-Type') -# if content_type is None or not content_type.lower().startswith('application/json'): -# logging.error( -# f"request with wrong content type made by {request.remote_addr}" -# ) -# return jsonify(status='unsupported media type'), 415 - -# @app.route('/test', methods=['POST']) -# def test(): -# logging.debug('Content-Type: ' + request.headers.get('Content-Type')) -# logging.debug(request.get_json(force=True)) -# return jsonify(status='success', sender=request.remote_addr), 200 + """ Handle event from webhook. """ + # stop early if allowed + commit_msg = request.head_commit['message'] + if commit_msg.lower().startswith('[skip ci]'): + return {'status': 'received task'} + # clone repository + repo_url = request.repository['clone_url'] + clone_repository(repo_url) + return if __name__ == '__main__': - load_dotenv() - # prepare variables - # serve( - # app=app, - # host=listen_ip, - # port=listen_port - # ) uvicorn.run( app=app, host='0.0.0.0'