diff --git a/.gitignore b/.gitignore index e928de1..f9b1113 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] -*$py.class \ No newline at end of file +*$py.class +/env \ No newline at end of file diff --git a/HelloWorld.db b/HelloWorld.db new file mode 100644 index 0000000..6903412 Binary files /dev/null and b/HelloWorld.db differ diff --git a/README.md b/README.md index 5bdcb75..48e2f1c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,11 @@ # IWS_clean_architecture -** Master MDS HSMA ** -Clean Architecture - Architekturstil am praktischen Beispiel z.B. in Python. \ No newline at end of file +** Master MDS HSMA ** +Clean Architecture - Architekturstil am praktischen Beispiel z.B. in Python. + +## Setup Test +1. falls python noch nicht installiert, installieren +2. ```pip install -r requirements.txt``` +3. ```python main.py``` und Terminal offen lassen +4. index.html mit Browser öffnen +5. Wenn alles geklappt hat sollte die index.html Hello World anzeigen \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..a99ef05 --- /dev/null +++ b/index.html @@ -0,0 +1,26 @@ + + + + + + Setup Test + + +

Not Working

+ + + + diff --git a/main.py b/main.py new file mode 100644 index 0000000..4020ace --- /dev/null +++ b/main.py @@ -0,0 +1,26 @@ +import sqlite3 +from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware +import uvicorn + +app = FastAPI() +# Allow CORS for all origins (for simplicity) +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + + +@app.get("/greetings") +async def get_greetings(): + connection = sqlite3.connect("HelloWorld.db") + cursor = connection.cursor() + cursor.execute("SELECT * FROM greetings") + rows = cursor.fetchall() + return {"greetings": rows} + +if __name__ == "__main__": + uvicorn.run(app, host="127.0.0.1", port=8000) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f0615cf --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +fastapi +uvicorn \ No newline at end of file