Deploy Your Final Project
Use this guide to put your final project on Render’s Free plan.
Set Up Render
Keep your code on GitHub. Render runs a copy of your Python server and gives the site a public URL you can share for live grading. Follow these steps from Render’s FastAPI guide, using your existing final-project repository:
Commit and push the app,
requirements.txt, templates, static files,db_create.py, andschema.sql. Includeuvicorn,jinja2,python-multipart, and any other packages your app imports inrequirements.txt. Keep.envand your local database out of git.Add a file named
.python-versioncontaining3.12to the repository root, then commit and push it. This selects the course’s Python version on Render; see Render’s Python-version instructions.Sign up for Render, choose New → Web Service, and connect your GitHub repository. Select your final-project branch, usually
main.Select Python 3 and the Free instance type. Set the build command to
python -m pip install -r requirements.txt.Set the start command to:
python -m uvicorn app:app --host 0.0.0.0 --port $PORTReplace
app:appif your module or FastAPI variable has a different name. Enter$PORTliterally in Render’s start-command field; Render supplies its value. The command assumes your app and dependency file are in the repository root. If they are in a subfolder, set Render’s Root Directory to that folder.If your app needs API keys or a session secret, add those values in Render’s Environment settings. Keep them out of GitHub.
Deploy, wait for the service to become live, and open its
https://…onrender.comURL. If deployment fails, read the build or runtime logs to find the missing package, file, or setting.
Before the final, stop your local server and have a classmate open the hosted URL on another computer, create an account, log in, and post a message. Check that the page’s CSS and images load too. After changing your code, push it and confirm that Render has successfully deployed the commit you will demonstrate.
Data and Restarts
Render’s free services sleep after 15 minutes without traffic and can take about a minute to wake up. Their local SQLite data is lost when the service sleeps, restarts, or redeploys. These resets do not lose project points. Your local database must still preserve data across local server restarts.
The starter’s create_app calls initialize_database at startup. If the database is missing, the app creates it from schema.sql. Put any sample accounts or posts for your demo in that setup so they’ll be there again after a reset. If the file already exists, the app should keep its accounts and posts.
Open your hosted URL a few minutes before your appointment, allow it to wake up, and check the demo data. Submit the Render URL, not a localhost address or a temporary tunnel link. The Free plan meets the requirement; paid storage and a custom domain are not required.