feat:完成微信公众号的自动化工具
This commit is contained in:
40
app/main.py
Normal file
40
app/main.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
from app.config import settings
|
||||
from app.schemas import IMPublishRequest, RewriteRequest, WechatPublishRequest
|
||||
from app.services.ai_rewriter import AIRewriter
|
||||
from app.services.im import IMPublisher
|
||||
from app.services.wechat import WechatPublisher
|
||||
|
||||
app = FastAPI(title=settings.app_name)
|
||||
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
||||
templates = Jinja2Templates(directory="app/templates")
|
||||
|
||||
rewriter = AIRewriter()
|
||||
wechat = WechatPublisher()
|
||||
im = IMPublisher()
|
||||
|
||||
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
async def index(request: Request):
|
||||
return templates.TemplateResponse("index.html", {"request": request, "app_name": settings.app_name})
|
||||
|
||||
|
||||
@app.post("/api/rewrite")
|
||||
async def rewrite(req: RewriteRequest):
|
||||
return rewriter.rewrite(req)
|
||||
|
||||
|
||||
@app.post("/api/publish/wechat")
|
||||
async def publish_wechat(req: WechatPublishRequest):
|
||||
return await wechat.publish_draft(req)
|
||||
|
||||
|
||||
@app.post("/api/publish/im")
|
||||
async def publish_im(req: IMPublishRequest):
|
||||
return await im.publish(req)
|
||||
Reference in New Issue
Block a user