Skip to content

Instantly share code, notes, and snippets.

@LaurentDumont
Last active April 18, 2021 20:28
Show Gist options
  • Save LaurentDumont/202cfe71bbe56b08cf6fe1a9805fd979 to your computer and use it in GitHub Desktop.
Save LaurentDumont/202cfe71bbe56b08cf6fe1a9805fd979 to your computer and use it in GitHub Desktop.
blocking_fastapi.py
from fastapi import FastAPI, Request, BackgroundTasks, Depends
from fastapi.responses import JSONResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
import re
from bs4 import BeautifulSoup
import requests
templates = Jinja2Templates(directory="./templates")
headers = {
'User-Agent': 'potato tomato 2021',
'Content-Type': 'application/x-www-form-urlencoded'
}
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
URL = "https://steamcommunity.com/sharedfiles/filedetails/?id=569264526"
def get_stuff():
response = requests.get('https://steamcommunity.com/sharedfiles/filedetails/?id=678291222')
response.raise_for_status
content = response.text
raw_data = 'start=0&count=99999'
url = 'https://steamcommunity.com/comment/PublishedFile_Public/render/76561197988486167/678291222/'
comment_response = requests.post(url, data=raw_data, headers=headers)
print(comment_response.status_code)
comment_response.raise_for_status
json_comments_data = comment_response.json()
return('potato')
@app.get("/steam")
def get_steam(request: Request):
get_stuff()
return templates.TemplateResponse("index.html", {"request": request})
@app.get("/potato")
def potato():
return('potato')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment