Skip to content
Snippets Groups Projects
Commit 6ea8858e authored by Mia Wang's avatar Mia Wang
Browse files

download button

parent 49208f30
No related branches found
No related tags found
No related merge requests found
Showing
with 317 additions and 8 deletions
No preview for this file type
FLASK_APP=autoaugmentation
\ No newline at end of file
FLASK_APP=auto_augmentation
\ No newline at end of file
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
build-job:
stage: build
script:
- echo "Hello, I'm Building"
- pip install pytest
- pip install flask
- pip install pandoc # for pdf making
- pip install weasyprint # for pdf making
test-job:
stage: test
script:
- echo "Now I'm Testing!"
- python3 -m tests.test_query_processor
deploy-job:
stage: deploy
script:
- echo "Now I'm Deploying to VM!"
- python3 -m venv venv
- . venv/bin/activate
- pip install -r requirements.txt
- flask run &
- echo "Now I'm Deploying to Heroku!"
- dpl --provider=heroku --app=yw21218-simplewebapp --api-key=5ccc3ae7-725e-4f9f-b441-0c9a28ebdc1b
FROM python:3
RUN pip3 install virtualenv
RUN python3 -m venv venvs
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY . .
CMD ["flask", "run"]
\ No newline at end of file
web: flask run --host=0.0.0.0 --port=$PORT
No preview for this file type
import os
from flask import Flask, render_template, request, flash
def create_app(test_config=None):
# create and configure the app
app = Flask(__name__, instance_relative_config=True)
app.config.from_mapping(
SECRET_KEY='dev',
)
if test_config is None:
# load the instance config, if it exists, when not testing
app.config.from_pyfile('config.py', silent=True)
else:
# load the test config if passed in
app.config.from_mapping(test_config)
# ensure the instance folder exists
os.makedirs(app.instance_path, exist_ok=True)
from auto_augmentation import search_page, search_result, download_file
app.register_blueprint(search_page.bp)
app.register_blueprint(search_result.bp)
app.register_blueprint(download_file.bp)
return app
from flask import Blueprint, request, render_template, flash, send_file
bp = Blueprint("download_file", __name__)
@bp.route("/download_file", methods=["GET"])
@bp.route("/choose_file", methods=["GET", "POST"])
def download():
# Setup for the 'return send_file()' function call at the end of this function
path = 'templates/CNN.zip' # e.g. 'templates/download.markdown'
return send_file(path,
as_attachment=True)
from flask import Blueprint, render_template
bp = Blueprint("home", __name__)
@bp.route("/")
def index():
return render_template("home.html")
from flask import Blueprint, render_template
bp = Blueprint("home", __name__)
@bp.route("/")
def index():
return render_template("home.html")
from flask import Blueprint, request, render_template, flash, send_file
import subprocess
bp = Blueprint("search_result", __name__)
@bp.route("/search_result", methods=["GET", "POST"])
@bp.route("/choose_type", methods=["GET", "POST"])
def response():
query = request.args["search_query"]
if not query:
flash("No query")
print('query', query)
return render_template("result.html")
\ No newline at end of file
<!doctype html>
<html>
<head>
{% block head %}
<title>{% block title %}{% endblock %} - Meta Reinforcement Learning for Data Augmentation</title>
{% endblock %}
</head>
<body>
{% block body %}{% endblock %}
</body>
</html>
{% extends "basic.html" %}
{% block title%}Home{% endblock %}
{% block body %}
Search some literature:
<form action="/search_result">
<label for="search_query">Query:</label>
<input type="text" id="search_query" name="search_query"><br>
<input type="submit">
</form>
{% endblock %}
{% extends "basic.html" %}
{% block title%}Home{% endblock %}
{% block body %}
Training the model...
{% endblock %}
\ No newline at end of file
{% extends "basic.html" %}
{% block title %}Response{% endblock %}
{% block body %}
Response to query:<br>
<ul>
{% for result in search_results %}
<li> {{ result }}
{% endfor %}
</ul>
<div>
<form action="/choose_file">
<input type="radio" id="downloadTypeChoice1"
name="Filetype" value="html">
<label for="downloadChoice1">HTML</label><br>
<input type="radio" id="downloadTypeChoice2"
name="Filetype" value="markdown">
<label for="downloadTypeChoice2">Markdown</label><br>
<input type="radio" id="downloadTypeChoice3"
name="Filetype" value="pdf">
<label for="downloadTypeChoice3">PDF</label><br>
<input type="submit">
</form>
</div>
{% endblock %}
build:
docker:
web: Dockerfile # path to your Dockerfile
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment