Skip to content

Commit

Permalink
Added upload
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed May 12, 2022
1 parent 609bfbe commit 716ffb9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pyenzyme_server.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os

from fastapi import FastAPI, UploadFile, File, Request, Body
from starlette.responses import FileResponse, JSONResponse
from starlette.responses import FileResponse, JSONResponse, HTMLResponse
from starlette.background import BackgroundTasks
from fastapi.templating import Jinja2Templates
from fastapi.staticfiles import StaticFiles

from pyenzyme.enzymeml.core.enzymemldocument import EnzymeMLDocument
from pyenzyme.enzymeml.core.measurement import Measurement
Expand All @@ -21,6 +23,11 @@
# * Settings
app = FastAPI(title="PyEnzyme REST-API", version="1.2", docs_url="/")

app.mount("/static", StaticFiles(directory="static"), name="static")

templates = Jinja2Templates(directory="static")


# * Functions


Expand Down Expand Up @@ -208,6 +215,15 @@ async def get_enzymeml_template():
)


@app.get(
"/template/upload",
summary="Upload the EnzymeML spreadsheet template and convert it to EnzymeML.",
tags=["EnzymeML spreadsheet"],
)
def upload_enzymeml_template(request: Request, response_class=HTMLResponse):
return templates.TemplateResponse("upload.html", {"request": request})


@app.post(
"/template/convert",
summary="Converts an EnzymeML spreadsheet template to an EnzymeML document.",
Expand Down
22 changes: 22 additions & 0 deletions static/upload.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<html>
<head>
<img alt="Qries" src="https://enzymeml.org/images/logo/enzymeml.jpg" width=300>
<style>
body {
font-family: Verdana, sans-serif;
}
</style>
</head>
<body>
<h2><strong>EnzymeML-Template conversion</strong></h2>
<p>Please upload your <a href="https://enzymeml.sloppy.zone/template/download">EnzymeML spreadsheet</a> via the following form.</p>
<p>In return you will receive the corresponding OMEX file.</p>
<p>&nbsp;</p>
<p><form action = "https://enzymeml.sloppy.zone/template/convert" method = "POST"
enctype = "multipart/form-data">
<input type = "file" name = "enzymeml_template" />
<input type = "submit"/>
</form></p>

</body>
</html>

0 comments on commit 716ffb9

Please sign in to comment.