Skip to content

Commit

Permalink
Add home page template
Browse files Browse the repository at this point in the history
For the moment, templates are outside the code directory. I'm not
sure if this is the ideal direction; it depends what deployment
looks like.
  • Loading branch information
PeterJCLaw committed Jun 26, 2020
1 parent e6ab224 commit e0f1418
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ insert_final_newline = true
[*.py]
indent_size = 4

[*.md]
[*.{md,html}]
indent_size = 2
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
},

"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.pylintEnabled": false,
Expand Down
13 changes: 8 additions & 5 deletions code_submitter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from starlette.routing import Route
from starlette.requests import Request
from starlette.responses import HTMLResponse
from starlette.responses import Response
from starlette.templating import Jinja2Templates
from starlette.applications import Starlette

templates = Jinja2Templates(directory='templates')

async def homepage(request: Request) -> HTMLResponse:
return HTMLResponse('')

async def homepage(request: Request) -> Response:
return templates.TemplateResponse('index.html', {'request': request})

async def upload(request: Request) -> HTMLResponse:
return HTMLResponse('')

async def upload(request: Request) -> Response:
return Response('')


routes = [
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@

install_requires=[
'starlette',
'jinja2',
],
)
34 changes: 34 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Virtual Competition Code Submission &mdash; Student Robotics</title>

<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk"
crossorigin="anonymous"
/>
</head>
<body>
<div class="container">
<h1>Virtual Competition Code Submission</h1>
<div class="row">
<form action="{{ url_for('upload') }}" method="POST" class="col-sm-6">
<div class="form-group">
<label for="archive"> Select ZIP archive </label>
<input
class="form-control"
type="file"
name="archive"
placeholder="robot.zip"
accept="application/zip,.zip"
required
/>
</div>
<button class="btn btn-primary" type="submit">Upload</button>
</form>
</div>
</div>
</body>
</html>

0 comments on commit e0f1418

Please sign in to comment.