Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
from fastapi import FastAPI, Request, HTTPException, UploadFile, File, Form, BackgroundTasks
|
| 2 |
from pydantic import BaseModel
|
| 3 |
import uuid
|
| 4 |
-
from fastapi.responses import RedirectResponse
|
| 5 |
from fastapi.middleware.cors import CORSMiddleware
|
| 6 |
import os
|
| 7 |
import requests
|
|
@@ -15,7 +15,7 @@ deployments = {}
|
|
| 15 |
# GitHub OAuth config (replace with your own client_id and client_secret)
|
| 16 |
GITHUB_CLIENT_ID = os.getenv("GITHUB_CLIENT_ID", "your_github_client_id")
|
| 17 |
GITHUB_CLIENT_SECRET = os.getenv("GITHUB_CLIENT_SECRET", "your_github_client_secret")
|
| 18 |
-
GITHUB_OAUTH_REDIRECT = os.getenv("GITHUB_OAUTH_REDIRECT", "
|
| 19 |
|
| 20 |
# In-memory user token storage (for demo; use DB in production)
|
| 21 |
user_tokens = {}
|
|
@@ -109,7 +109,7 @@ def github_callback(code: str, state: str):
|
|
| 109 |
token = resp.json().get("access_token")
|
| 110 |
if token:
|
| 111 |
user_tokens[state] = token
|
| 112 |
-
return RedirectResponse(url=f"https://t.me/
|
| 113 |
return {"error": "Failed to get token"}
|
| 114 |
|
| 115 |
@app.get("/github/repos")
|
|
@@ -149,4 +149,9 @@ def get_logs(deploy_id: str, last_line: int = 0):
|
|
| 149 |
"logs": logs[last_line:],
|
| 150 |
"next_line": len(logs),
|
| 151 |
"status": status
|
| 152 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI, Request, HTTPException, UploadFile, File, Form, BackgroundTasks
|
| 2 |
from pydantic import BaseModel
|
| 3 |
import uuid
|
| 4 |
+
from fastapi.responses import RedirectResponse, PlainTextResponse
|
| 5 |
from fastapi.middleware.cors import CORSMiddleware
|
| 6 |
import os
|
| 7 |
import requests
|
|
|
|
| 15 |
# GitHub OAuth config (replace with your own client_id and client_secret)
|
| 16 |
GITHUB_CLIENT_ID = os.getenv("GITHUB_CLIENT_ID", "your_github_client_id")
|
| 17 |
GITHUB_CLIENT_SECRET = os.getenv("GITHUB_CLIENT_SECRET", "your_github_client_secret")
|
| 18 |
+
GITHUB_OAUTH_REDIRECT = os.getenv("GITHUB_OAUTH_REDIRECT", "http://localhost:7860/github/callback")
|
| 19 |
|
| 20 |
# In-memory user token storage (for demo; use DB in production)
|
| 21 |
user_tokens = {}
|
|
|
|
| 109 |
token = resp.json().get("access_token")
|
| 110 |
if token:
|
| 111 |
user_tokens[state] = token
|
| 112 |
+
return RedirectResponse(url=f"https://t.me/your_bot_username?start=github_connected")
|
| 113 |
return {"error": "Failed to get token"}
|
| 114 |
|
| 115 |
@app.get("/github/repos")
|
|
|
|
| 149 |
"logs": logs[last_line:],
|
| 150 |
"next_line": len(logs),
|
| 151 |
"status": status
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
@app.get("/logs/{deploy_id}/download")
|
| 155 |
+
def download_logs(deploy_id: str):
|
| 156 |
+
logs = deploy_logs.get(deploy_id, [])
|
| 157 |
+
return PlainTextResponse('\n'.join(logs), media_type='text/plain')
|