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
1 parent
9159030
commit c6817a2
Showing
7 changed files
with
84 additions
and
5 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
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 |
---|---|---|
@@ -1,7 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
def main(): | ||
print("Hello MoeFlow!") | ||
import jinja2 | ||
import logging | ||
import os | ||
from sanic import Sanic, response | ||
from moeflow.jinja2_env import render | ||
|
||
app = Sanic(__name__) | ||
dir_path = os.path.dirname(os.path.realpath(__file__)) | ||
app.static('/static', os.path.join(dir_path, '..', 'static')) | ||
|
||
|
||
@app.route("/", methods=['GET', 'POST']) | ||
async def hello_world(request): | ||
if request.method == "POST": | ||
uploaded_image = request.files.get('uploaded_image') | ||
logging.info(uploaded_image.name) | ||
return response.html(render("main.html")) | ||
|
||
|
||
def main(): | ||
# Set logger | ||
logging.basicConfig(level=logging.INFO) | ||
app.run(host="0.0.0.0", port=8888) | ||
|
||
if __name__ == '__main__': | ||
main() | ||
|
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,13 @@ | ||
import os | ||
|
||
import jinja2 | ||
|
||
dir_path = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
|
||
def render(tpl_path, context={}): | ||
return jinja2.Environment( | ||
loader=jinja2.FileSystemLoader( | ||
os.path.join(dir_path, 'templates') | ||
) | ||
).get_template(tpl_path).render(context) |
Empty file.
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,19 @@ | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> | ||
<title>MoeFlow: Anime Characters Recognition</title> | ||
<link rel="stylesheet" type="text/css" href="./static/main.css"> | ||
</head> | ||
<body> | ||
<h2>MoeFlow: Anime Characters Recognition (Alpha Ver.)</h2> | ||
<p>For more information, see <a href="https://github.com/freedomofkeima/transfer-learning-anime" target="_blank">freedomofkeima/transfer-learning-anime</a> at Github.</p> | ||
<form method="POST" enctype="multipart/form-data"> | ||
<input type="file" name="uploaded_image" accept="image/*"> | ||
<input type="submit"> | ||
</form> | ||
<div id="footer"> | ||
<p>Freedomofkeima Zone, 2017.</p> | ||
</div> | ||
</body> | ||
</html> | ||
|
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,7 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
from moeflow.cmds.main import main | ||
from moeflow.cmds.main import hello_world | ||
|
||
|
||
def test_main(): | ||
main() | ||
def test_hello_world(): | ||
hello_world(object()) | ||
assert True |