Skip to content

Instantly share code, notes, and snippets.

@haa-zee
haa-zee / async_fileread_by_chatgpt.py
Created October 30, 2023 14:21
asyncio file read
import asyncio
async def read_lines(file_path, lines):
with open(file_path, 'r') as file:
return [await file.readline() for _ in range(lines)]
async def main():
file_path = "jou.txt"
lines = [5, 10, 15]
tasks = [asyncio.create_task(read_lines(file_path, line)) for line in lines]
@haa-zee
haa-zee / index_by_chatgpt.py
Created October 30, 2023 14:15
index_by_chatgpt.py
import os
from flask import Flask, render_template, request, send_file
app = Flask(__name__)
@app.route('/')
def index():
dir_path = os.path.abspath('.')
contents = os.listdir('.')
files = []