Ive waitet way too long
This commit is contained in:
BIN
app/__pycache__/main.cpython-312.pyc
Normal file
BIN
app/__pycache__/main.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/__pycache__/main.cpython-313.pyc
Normal file
BIN
app/__pycache__/main.cpython-313.pyc
Normal file
Binary file not shown.
BIN
app/files/UE 9 (1).pdf
Normal file
BIN
app/files/UE 9 (1).pdf
Normal file
Binary file not shown.
BIN
app/files/türschild_ausdrucken.pdf
Normal file
BIN
app/files/türschild_ausdrucken.pdf
Normal file
Binary file not shown.
45
app/main.py
Normal file
45
app/main.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from typing import Annotated
|
||||
from typing import List, Dict, Tuple
|
||||
from datetime import date
|
||||
from fastapi import FastAPI, File, UploadFile, Request, Form
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.mount("/static", StaticFiles(directory="./"), name="static")
|
||||
|
||||
|
||||
@app.post("/files/")
|
||||
async def create_file(file: Annotated[bytes, File()]):
|
||||
return {"filesize": len(file)}
|
||||
|
||||
|
||||
@app.post("/uploadfile/")
|
||||
async def create_upload_file(file: UploadFile):
|
||||
content = await file.read()
|
||||
filename = file.filename if file.filename is not None else "None"
|
||||
with open("./app/files/" + filename, "wb") as f:
|
||||
f.write(content)
|
||||
app.mount("/files", StaticFiles(directory="./app/files/"), name="files")
|
||||
return {"filename": filename, "path": "/files/" + filename}
|
||||
|
||||
|
||||
@app.post("/submit/")
|
||||
async def get_submittion(
|
||||
lva: Annotated[str, Form()],
|
||||
prof: Annotated[str, Form()],
|
||||
fname: Annotated[str, Form()],
|
||||
sem: Annotated[str, Form()],
|
||||
stype: Annotated[str, Form()],
|
||||
date: Annotated[str, Form()],
|
||||
rects: Annotated[str, Form()], # List[List[Tuple[float, float, float, float]]],
|
||||
pagescales: Annotated[str, Form()], # Annotated[List[Dict[str, float]], Form()],
|
||||
):
|
||||
print(lva, prof, fname, stype, sem, date, rects, pagescales)
|
||||
return {"done": "ok"}
|
||||
|
||||
|
||||
# async def get_submittion(request: Request):
|
||||
# reqJson = await request.form()
|
||||
# print(reqJson)
|
||||
# return {"done": "ok"}
|
||||
21
app/main_flask.py_
Normal file
21
app/main_flask.py_
Normal file
@@ -0,0 +1,21 @@
|
||||
import flask
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
app.secret_key = "test"
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def view_index():
|
||||
return flask.render_template("../index.html")
|
||||
|
||||
|
||||
@app.route("/handle_post", methods=["POST"])
|
||||
def handle_post():
|
||||
if request.method == "POST":
|
||||
file = request.args.get("file")
|
||||
print(file)
|
||||
return flask.render_template("../index.html")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
Reference in New Issue
Block a user