commit 0f71fc4459e4b6d1dc166c49a5d186f16790f59b Author: Xevion Date: Tue Sep 10 16:04:15 2024 -0500 project init diff --git a/README.md b/README.md new file mode 100644 index 0000000..0be2fa5 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# linkpulse + +This is an empty project right now. It merely holds a simplistic FastAPI server to showcase Railway. + diff --git a/main.py b/main.py new file mode 100644 index 0000000..405a287 --- /dev/null +++ b/main.py @@ -0,0 +1,11 @@ +from fastapi import FastAPI, Request +from datetime import datetime + +app = FastAPI() + + +@app.get("/") +async def get_current_time(request: Request): + current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + user_ip = request.headers.get("X-Forwarded-For") + return {"time": current_time, "ip": user_ip} diff --git a/railway.json b/railway.json new file mode 100644 index 0000000..150b03c --- /dev/null +++ b/railway.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://railway.app/railway.schema.json", + "build": { + "builder": "NIXPACKS" + }, + "deploy": { + "startCommand": "hypercorn main:app --bind \"[::]:$PORT\"" + } +} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ec59348 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +fastapi==0.100.0 +hypercorn==0.14.4 \ No newline at end of file