From 6b152424bec760089b7859cc294d0bed3610b2b7 Mon Sep 17 00:00:00 2001 From: liuyalin Date: Tue, 27 Aug 2024 08:57:51 +0800 Subject: [PATCH] vercel deploy --- api/streamlit_app.py | 26 ++++++++++++++++++++++++++ build.sh | 5 +++++ runtime.txt | 1 + vercel.json | 19 +++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 api/streamlit_app.py create mode 100644 build.sh create mode 100644 runtime.txt create mode 100644 vercel.json diff --git a/api/streamlit_app.py b/api/streamlit_app.py new file mode 100644 index 0000000..1b104c0 --- /dev/null +++ b/api/streamlit_app.py @@ -0,0 +1,26 @@ +from pathlib import Path +import streamlit as st +from streamlit.web.bootstrap import run + +def streamlit_app(): + # 这里导入并运行您的主 Streamlit 应用 + import superexcel.main + +async def asgi_app(scope, receive, send): + if scope["type"] == "http": + run(streamlit_app, "", [], flag_options={}) + return + await send({ + "type": "http.response.start", + "status": 200, + "headers": [ + [b"content-type", b"text/plain"], + ], + }) + await send({ + "type": "http.response.body", + "body": b"Hello, World!", + }) + +# 这个变量名很重要,Vercel 会查找它 +app = asgi_app \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..246545c --- /dev/null +++ b/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash +python -m venv .venv +source .venv/bin/activate +pip install --upgrade pip +pip install -r requirements.txt \ No newline at end of file diff --git a/runtime.txt b/runtime.txt new file mode 100644 index 0000000..5509089 --- /dev/null +++ b/runtime.txt @@ -0,0 +1 @@ +python-3.10 diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..ac98256 --- /dev/null +++ b/vercel.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "builds": [ + { + "src": "superexcel/main.py", + "use": "@vercel/python", + "config": { "maxLambdaSize": "15mb" } + } + ], + "routes": [ + { + "src": "/(.*)", + "dest": "superexcel/main.py" + } + ], + "env": { + "PYTHONPATH": "/var/task" + } + } \ No newline at end of file