wide-midnight-78598
06/24/2024, 7:33 PM1 # /// script
2 # dependencies = [
3 # "uvicorn",
4 # "fastapi",
5 # ]
6 # requires-python = ">=3.12"
7 # ///
8
9 import uvicorn
10 from fastapi import FastAPI
11
12 app = FastAPI()
13
14
15 @app.get("/")
16 async def root():
17 return {"message": "Hello World"}
18
19 if __name__ == "__main__":
20 uvicorn.run(app, host="localhost", port=8000)
scratch/pex-260 % ve
(.venv) scratch/pex-260 % pip install --upgrade pex
Collecting pex
Using cached pex-2.6.0-py2.py3-none-any.whl.metadata (7.4 kB)
Using cached pex-2.6.0-py2.py3-none-any.whl (3.4 MB)
Installing collected packages: pex
Successfully installed pex-2.6.0
(.venv) scratch/pex-260 % pex --exe ./test.py
INFO: Started server process [48812]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on <http://localhost:8000> (Press CTRL+C to quit)