-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
339 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
# Fastapi-starter | ||
# Fastapi Web Starter | ||
|
||
You can find the Medium article at [https://shinichiokada.medium.com/](https://shinichiokada.medium.com/). | ||
|
||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import os.path | ||
import markdown | ||
|
||
|
||
def openfile(filename): | ||
filepath = os.path.join("app/pages/", filename) | ||
with open(filepath, "r", encoding="utf-8") as input_file: | ||
text = input_file.read() | ||
|
||
html = markdown.markdown(text) | ||
data = { | ||
"text": html | ||
} | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# About | ||
|
||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse velit nunc, tincidunt sed tempus eget, luctus venenatis ex. Morbi et felis pharetra, rhoncus erat et, feugiat ipsum. Nunc lorem elit, pellentesque ac magna et, luctus volutpat odio. Suspendisse potenti. Praesent interdum ligula nunc, non tempor mi congue et. Pellentesque tellus neque, lacinia vitae auctor ac, interdum ac mauris. Suspendisse et nunc in nibh iaculis semper vel ac sem. In vel eros eget ipsum semper dapibus vel in nibh. Nunc ac augue id nulla ultrices porta. Nullam consectetur sed purus eu congue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Contact | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse velit nunc, tincidunt sed tempus eget, luctus venenatis ex. Morbi et felis pharetra, rhoncus erat et, feugiat ipsum. Nunc lorem elit, pellentesque ac magna et, luctus volutpat odio. Suspendisse potenti. Praesent interdum ligula nunc, non tempor mi congue et. Pellentesque tellus neque, lacinia vitae auctor ac, interdum ac mauris. Suspendisse et nunc in nibh iaculis semper vel ac sem. In vel eros eget ipsum semper dapibus vel in nibh. Nunc ac augue id nulla ultrices porta. Nullam consectetur sed purus eu congue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
# Welcome to FastAPI Starter | ||
|
||
|
||
This project uses [FastAPI](https://fastapi.tiangolo.com/), [Jinja2](https://jinja.palletsprojects.com/en/2.11.x/), and [Bootstrap4](https://getbootstrap.com/docs/4.1/getting-started/introduction/). | ||
|
||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Information | ||
|
||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse velit nunc, tincidunt sed tempus eget, luctus venenatis ex. Morbi et felis pharetra, rhoncus erat et, feugiat ipsum. Nunc lorem elit, pellentesque ac magna et, luctus volutpat odio. Suspendisse potenti. Praesent interdum ligula nunc, non tempor mi congue et. Pellentesque tellus neque, lacinia vitae auctor ac, interdum ac mauris. Suspendisse et nunc in nibh iaculis semper vel ac sem. In vel eros eget ipsum semper dapibus vel in nibh. Nunc ac augue id nulla ultrices porta. Nullam consectetur sed purus eu congue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Portfolio | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse velit nunc, tincidunt sed tempus eget, luctus venenatis ex. Morbi et felis pharetra, rhoncus erat et, feugiat ipsum. Nunc lorem elit, pellentesque ac magna et, luctus volutpat odio. Suspendisse potenti. Praesent interdum ligula nunc, non tempor mi congue et. Pellentesque tellus neque, lacinia vitae auctor ac, interdum ac mauris. Suspendisse et nunc in nibh iaculis semper vel ac sem. In vel eros eget ipsum semper dapibus vel in nibh. Nunc ac augue id nulla ultrices porta. Nullam consectetur sed purus eu congue. |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from fastapi import FastAPI, Request, Form, APIRouter | ||
from fastapi.responses import HTMLResponse | ||
from fastapi.templating import Jinja2Templates | ||
|
||
router = APIRouter() | ||
templates = Jinja2Templates(directory="templates/") | ||
|
||
|
||
@router.get("/accordion", response_class=HTMLResponse) | ||
def get_accordion(request: Request): | ||
result = "Type a number" | ||
return templates.TemplateResponse('accordion.html', context={'request': request, 'result': result}) | ||
|
||
|
||
@router.post("/accordion", response_class=HTMLResponse) | ||
def post_accordion(request: Request, tag: str = Form(...)): | ||
|
||
return templates.TemplateResponse('accordion.html', context={'request': request, 'tag': tag}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from fastapi import FastAPI, Request, Form, APIRouter | ||
from fastapi.responses import HTMLResponse | ||
from fastapi.templating import Jinja2Templates | ||
import os | ||
|
||
router = APIRouter() | ||
templates = Jinja2Templates(directory="templates/") | ||
|
||
|
||
@router.get("/twoforms", response_class=HTMLResponse) | ||
def form_get(request: Request): | ||
key = os.getenv("unsplash_key") | ||
print(key) | ||
result = "Type a number" | ||
return templates.TemplateResponse('twoforms.html', context={'request': request, 'result': result}) | ||
|
||
|
||
@router.post("/form1", response_class=HTMLResponse) | ||
def form_post1(request: Request, number: int = Form(...)): | ||
result = number + 2 | ||
return templates.TemplateResponse('twoforms.html', context={'request': request, 'result': result, 'yournum': number}) | ||
|
||
|
||
@router.post("/form2", response_class=HTMLResponse) | ||
def form_post2(request: Request, number: int = Form(...)): | ||
result = number + 100 | ||
return templates.TemplateResponse('twoforms.html', context={'request': request, 'result': result, 'yournum': number}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
from fastapi import Request, APIRouter, Depends | ||
from fastapi.responses import HTMLResponse | ||
from fastapi.templating import Jinja2Templates | ||
|
||
from dotenv import load_dotenv | ||
load_dotenv() | ||
|
||
templates = Jinja2Templates(directory="templates") | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/unsplash", response_class=HTMLResponse) | ||
async def unsplash_home(request: Request): | ||
key = os.getenv("unsplash_key") | ||
print(key) | ||
return templates.TemplateResponse("unsplash.html", {"request": request}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python-3.8.6 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
body { | ||
min-height: 100vh; | ||
position: relative; | ||
margin: 0; | ||
padding-bottom: 100px; | ||
box-sizing: border-box; | ||
} | ||
|
||
.wrapper{ | ||
max-width: 960px; | ||
} | ||
|
||
footer { | ||
position: absolute; | ||
bottom: 0; | ||
height: 100px; | ||
padding-top:50px; | ||
} | ||
|
||
.responsive{ | ||
max-width: 100%; | ||
height: auto; | ||
display: block; | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
|
||
#content{ | ||
position: relative; | ||
} | ||
|
||
.active { | ||
background-color: rgb(202, 249, 255); | ||
color: white; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{% extends "base.html" %} | ||
{% set active_page = "accordion" %} | ||
|
||
{% block title %}Accordion{% endblock %} | ||
|
||
{% block head %} | ||
{{ super() }} | ||
|
||
|
||
{% endblock %} | ||
|
||
{% block page_content %} | ||
<h1 class="cap">Accordion</h1> | ||
|
||
{% if tag %} | ||
<h2>You selected {{tag}}</h2> | ||
{% endif %} | ||
|
||
{% set flora = ['flower','tree','fruit','garden'] %} | ||
{% set fauna = [ 'cat', 'dog', 'bird', 'fish'] %} | ||
|
||
<form method="post" id="category"> | ||
<div class="accordion" id="accordionExample"> | ||
<div class="card"> | ||
<div class="card-header" id="headingOne"> | ||
<h2 class="mb-0"> | ||
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" | ||
aria-controls="collapseOne"> | ||
FLORA | ||
</button> | ||
|
||
</h2> | ||
</div> | ||
|
||
<div id="collapseOne" class="collapse | ||
{% for name in flora %} | ||
{% if name==tag %} | ||
show | ||
{% endif %} | ||
{% endfor %} | ||
" aria-labelledby="headingOne" data-parent="#accordionExample"> | ||
<div class="card-body"> | ||
{% for name in flora %} | ||
{% if tag == name %} | ||
{% set checked="checked" %} | ||
{% endif %} | ||
<div class="form-check form-check-inline"> | ||
<input class="form-check-input" type="radio" name="tag" id="radio-{{name}}" value="{{name}}" | ||
{{ checked }}> | ||
<label class="form-check-label" for="radio-{{name}}"> | ||
{{ name | capitalize}} | ||
</label> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="card"> | ||
<div class="card-header" id="headingTwo"> | ||
<h2 class="mb-0"> | ||
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" | ||
data-target="#collapseTwo" aria-controls="collapseTwo"> | ||
FAUNA | ||
</button> | ||
</h2> | ||
</div> | ||
<div id="collapseTwo" class="collapse | ||
{% for name in fauna %} | ||
{% if name==tag %} | ||
show | ||
{% endif %} | ||
{% endfor %} | ||
" aria-labelledby="headingTwo" data-parent="#accordionExample"> | ||
<div class="card-body"> | ||
{% for name in fauna %} | ||
{% if tag == name %} | ||
{% set checked="checked" %} | ||
{% endif %} | ||
<div class="form-check form-check-inline"> | ||
<input class="form-check-input" type="radio" name="tag" id="radio-{{name}}" value="{{name}}" | ||
{{ checked }}> | ||
<label class="form-check-label" for="radio-{{name}}"> | ||
{{ name | capitalize}} | ||
</label> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<button type="submit" class="submit btn btn-primary btn-xl">Submit</button> | ||
</form> | ||
|
||
{% endblock %} | ||
|
||
{% block scripts %} | ||
{{ super() }} | ||
|
||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,22 +10,17 @@ | |
<meta name="author" content="Shinichi Okada"> | ||
|
||
<title>{% block title %}{% endblock %} FastAPI Starter</title> | ||
<link rel="icon" href="{{ url_for('static', path='/images/favicon.png') }}" sizes="32x32" /> | ||
<link rel="icon" href="{{ url_for('static', path='/images/favicon.ico') }}" sizes="32x32" /> | ||
|
||
<!-- Bootstrap CSS CDN --> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" | ||
integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous"> | ||
<!-- Custom CSS --> | ||
<link href="{{ url_for('static', path='/css/style3.css') }}" rel="stylesheet"> | ||
<link href="{{ url_for('static', path='/css/mystyle.css') }}" rel="stylesheet"> | ||
|
||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> | ||
<!-- Font Awesome JS --> | ||
<script defer src="https://use.fontawesome.com/releases/v5.0.13/js/solid.js" | ||
integrity="sha384-tzzSw1/Vo+0N5UhStP3bvwWPq+uvzCMfrN1fEFe+xBmv1C/AtVX5K0uZtmcHitFZ" | ||
crossorigin="anonymous"></script> | ||
<script defer src="https://use.fontawesome.com/releases/v5.0.13/js/fontawesome.js" | ||
integrity="sha384-6OIrr52G08NpOFSZdxxz1xdNSndlD4vdcf/q2myIUVO0VsqaGHJsB0RaBE01VTOY" | ||
crossorigin="anonymous"></script> | ||
<script src="https://kit.fontawesome.com/543c4560e5.js" crossorigin="anonymous"></script> | ||
|
||
{% endblock %} | ||
</head> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<footer class="container"> | ||
<a href="#"><i class="fa fa-facebook">Facebook</i></a> | ||
<a href="#"><i class="fa fa-twitter">Twitter</i></a> | ||
</footer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.