KosiehBarter fe0cc790b4 Add Kubernetes deployments:
- Pod
- PersistentVolume
- PersistentVolumeClaim

Signed-off-by: Kosieh Barter <kaja.valek@gmail.com>
2023-10-13 15:21:47 +02:00
2023-10-13 15:21:47 +02:00
2023-09-27 09:10:41 +02:00

Python: Flask Test RESTful site (Frontend + API)

This project serves as a proof of working concept using Flask to serve both web user interface as well as RESTful API on same machine, yet utilizing different approaches with usage.

Goal of this project was to create a simple web/file server with Upload and Download capabilities, but also to provide file uploads using the REST API.

Basic information like upload time, name and size are present.

Purpose:

Flask is a Python's framework for hosting simple websites using Jinja templating system, which is also used in this repository. The goal was to set a simple web server to serve Web user interface for a simple file hosting system, as well as provide a REST API to upload / delete files from.

Formerly a SQLite database was planned to be used, but given the fact multiple threads causing database to crash unintentionally a system-oriented means of describing files was used.

Installation:

podman build -t <your_tag> .

How to run:

Specify your storage directory beforehand and then:

podman run -v /your/project/dir/data_storage/app/extFiles:z -p 5000:5000/tcp <your_tag>

In case of need of inspection:

podman exec -it <name_of_container> /bin/bash

Attach to container should set your directory to /app/, where are contents loaded.

  • Uploaded files are stored under extFiles directory, where can be operated on (Download, upload, both web + API)

Test with CURL:

# PUT
curl -v -X PUT -F "inFile=@/path/to/your/file" container_hostname:5000/api

# DELETE
curl -X DELETE container_hostname:5000/api:your_remote_file.txt

Test by Web-UI:

You can visit your project page in your browser by navigating to <container_hostname:5000> at your URL. Index page is meant for Proof of concept only, so expect rather crude design.

By visiting /api endpoint you will receive a JSON-compatible output of currently stored files, if any.

Known bugs:

Access / creation time on files is inaccurate, only the Day-Month-Year notations are correct. Suspected inconsistency either with Dockerized solution that relies on volume attaching as a dependency of start of the container, as solution is intended to be considered as microservice, compatible with Kubernetes.

Used Frameworks:

Python:

Flask:
* Web Interface
* REST API

Frontend:

Bootstrap 5 (JavaScript)
static/css/syle.css (minor tweaks)
S
Description
No description provided
Readme 36 KiB
Languages
Python 48.7%
HTML 39%
Dockerfile 7.9%
CSS 4.4%