Skip to content

Commit

Permalink
adding tutorial to deploy fastapi-server in aws-EC2
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard0803 committed Apr 17, 2024
1 parent aafa53d commit 45654a8
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions EC2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
host := $(value HOST)
key := $(value KEY)

ssh:
ssh -i "${key}" ${host}
1 change: 1 addition & 0 deletions EC2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### Tutorial to deploy fastapi server in aws-ec2
8 changes: 8 additions & 0 deletions EC2/fastapi_nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server {
listen 80;
server_name 52.42.65.162;
location / {
proxy_pass http://0.0.0.0:8000;
}
}

2 changes: 2 additions & 0 deletions EC2/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fastapi==0.99.1
uvicorn==0.22.0
27 changes: 27 additions & 0 deletions EC2/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

app = FastAPI()

app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"]
)


@app.get("/")
def root():
return {"message": "Hello World"}


if __name__ == "__main__":
import uvicorn
uvicorn.run(
app="server:app",
host="0.0.0.0",
port=8000,
reload=True,
)

0 comments on commit 45654a8

Please sign in to comment.