I was trying to deply my web application using quart
and hypercorn
but it raised:
TypeError: The response value type (coroutine) is not valid
I don't know what happened, this is my code:
# <!-- Dashboard -->
import os, quart
from hypercorn import Config; from hypercorn.asyncio import serve
from quart import Quart, redirect, render_template, url_for
from quart_discord import DiscordOAuth2Session, requires_authorization, Unauthorized
from discord.ext import ipc
dash = Quart(__name__)
config = Config()
config.bind = ["localhost:5000"]
dash.secret_key = 'smth'
dash.config['DISCORD_CLIENT_ID'] = "1067880974668533862"
dash.config['DISCORD_CLIENT_SECRET'] = "smth"
dash.config['DISCORD_REDIRECT_URI'] = "smth"
dash.config["DISCORD_BOT_TOKEN"] = "smth"
discord = DiscordOAuth2Session(dash)
# <!-- Code -->
import typing
@dash.route("/")
async def home():
"""
Home
"""
return render_template("index.html")
@dash.route("/login")
async def login():
return await discord.create_session()
@dash.route("/callback")
async def callback():
try:
await discord.callback()
except:
return redirect(url_for("/login"))
return redirect(url_for("/dashboard"))
@dash.route("/dashboard")
async def dashboard():
user = await discord.fetch_user()
return render_template("dashboard.html", user = user)
if __name__ == "__main__":
import asyncio
asyncio.run(serve(dash, config), debug=True)
Any help will be apprecciated!
render_template
must be awaited i.e. return await render_template
.