commit 233526754b0f171ab54492aaad85b47b8693f21d Author: HoseinA05 <139102040+HoseinA05@users.noreply.github.com> Date: Tue Dec 23 08:49:57 2025 +0000 Initial commit Created from https://vercel.com/new diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c3186d0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +.vercel/ +.venv/ +venv/ +__pycache__/ +*.pyc +*.pyo +*.pyd +.Python +.DS_Store +.env* diff --git a/README.md b/README.md new file mode 100644 index 0000000..99e23df --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# FastAPI Starter + +Deploy your [FastAPI](https://fastapi.tiangolo.com/) project to Vercel with zero configuration. + +[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/fastapi&template=fastapi) + +_Live Example: https://vercel-plus-fastapi.vercel.app/_ + +Visit the [FastAPI documentation](https://fastapi.tiangolo.com/) to learn more. + +## Getting Started + +Install the required dependencies: + +```bash +python -m venv .venv +source .venv/bin/activate +pip install . +``` + +Or, if using [uv](https://docs.astral.sh/uv/): + +```bash +uv sync +``` + + +## Running Locally + +Start the development server on http://0.0.0.0:5001 + +```bash +python main.py +# using uv: +uv run main.py +``` + +When you make changes to your project, the server will automatically reload. + +## Deploying to Vercel + +Deploy your project to Vercel with the following command: + +```bash +npm install -g vercel +vercel --prod +``` + +Or `git push` to your repository with our [git integration](https://vercel.com/docs/deployments/git). + +To view the source code for this template, [visit the example repository](https://github.com/vercel/vercel/tree/main/examples/fastapi). diff --git a/main.py b/main.py new file mode 100644 index 0000000..5c154bc --- /dev/null +++ b/main.py @@ -0,0 +1,349 @@ +from fastapi import FastAPI +from fastapi.responses import HTMLResponse + + +app = FastAPI( + title="Vercel + FastAPI", + description="Vercel + FastAPI", + version="1.0.0", +) + + +@app.get("/api/data") +def get_sample_data(): + return { + "data": [ + {"id": 1, "name": "Sample Item 1", "value": 100}, + {"id": 2, "name": "Sample Item 2", "value": 200}, + {"id": 3, "name": "Sample Item 3", "value": 300} + ], + "total": 3, + "timestamp": "2024-01-01T00:00:00Z" + } + + +@app.get("/api/items/{item_id}") +def get_item(item_id: int): + return { + "item": { + "id": item_id, + "name": "Sample Item " + str(item_id), + "value": item_id * 100 + }, + "timestamp": "2024-01-01T00:00:00Z" + } + + +@app.get("/", response_class=HTMLResponse) +def read_root(): + return """ + + + + + + Vercel + FastAPI + + + + +
+ +
+
+
+

Vercel + FastAPI

+
+
from fastapi import FastAPI
+
+app = FastAPI()
+
+@app.get("/")
+def read_root():
+    return {"Python": "on Vercel"}
+
+
+ +
+
+

Interactive API Docs

+

Explore this API's endpoints with the interactive Swagger UI. Test requests and view response schemas in real-time.

+ Open Swagger UI → +
+ +
+

Sample Data

+

Access sample JSON data through our REST API. Perfect for testing and development purposes.

+ Get Data → +
+ +
+
+ + + """ + + +if __name__ == "__main__": + import uvicorn + uvicorn.run("main:app", host="0.0.0.0", port=5001, reload=True) diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..cbe6034 Binary files /dev/null and b/public/favicon.ico differ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b71a65b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,8 @@ +[project] +name = "vercel-fastapi-starter" +version = "0.1.0" +requires-python = ">=3.10" +dependencies = [ + "fastapi>=0.121.0", + "uvicorn>=0.34.0", +] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..97dc7cd --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +fastapi +uvicorn