Welcome to Replit! This platform aims to show you a new workflow that can change the way you write code. This guide should give you a quick overview of the many features of our platform.
Don't worry if you are new to programming; we have tutorials to help you. To get you started, we have created these guides to get you coding in Python:
From your "My Repls" dashboard, you can create a new repl by clicking on the "+ New Repl" button at the top of your sidebar, or the blue "+" button in the top right corner of the page. This will bring you to a dialog box where you can specify your preferred language from a drop-down menu, and name your repl.
This will bring you to your workspace.
The right repl name and discription will help with organizing your repls, and make it easier to find your desired repl later. Once you have created your repl, you can edit its name and description:
There are three main parts to a repl:
Now that you have your repl sorted, it's time to start coding. In the Console, type the following and hit enter:
print("Hello World!")
Here, you can evaluate code line by line and interact with its results. Now let's try entering the following:
x = "hey"
Then type:
x * 3
Variables declared in the console persist, so you can continue to interact with variables there.
Now let's move over to the Editor in the middle. Type in the following code:
name = input("What's your name?")
print("Hello", name)
To run it, click on the big "Run" button at the top of the screen, or hit CTRL+Enter (Windows/Chromebook) or CMD+Enter (Mac).
You'll see the code run on the right hand side of the screen. Since the program is asking for input, go ahead and type your name in the console and hit enter. It should then greet you!
To demonstrate how to add packages, we are going to make a simple plot. Clear the code you have created up to now, and let's find a package. Packages are essentially directories which help us organize code without starting from scratch. We'll be using the matplotlib
package:
matplotlib
to search for the package. +
button to add it to your packages.This will create new files, pyproject.toml
and poetry.lock
, which contains all the package information for your repl, including the version number. It will also start installing on the right.
Now select main.py
to return to your program.
Let's enter the following code:
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.plot([1, 2, 4, 8, 16])
plt.savefig('plot.png')
Run the code. You'll see that the newly generated image, plot.png
, shows up in the filetree. Clicking on it will show you the image in the editor! We hope you love this feature as much as we do.
Learn more about plotting in Python.
Let's create a new Python3 repl. (Save time and use this shortcut). Let's call this one "python flask server".
Our first step is to add the flask
package. Go through the steps above except this time, choose the package called flask
.
Once finished, go back to main.py
and enter the following code:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_repler():
return 'Hello, Repler!'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080)
Hit run, and you'll see that a new pane has appeared with the URL for your repl's hosted site, along with a preview of what it looks like. You can share this link with your friends to show them the simple app that you made.
So far, your repl is public to everyone (unless you have a paid plan) and they can see the code that you put here. If you need to add some private information, such as an API key or a database password, you can use .env
files.
Create a new file by clicking on the "Add file" icon in your filetree. Name it .env
.
.env
files contain key-value pairs like the following. In the concole, type:
PASSWORD=pass1234
This .env
file is special because it is only visible to you. Anyone who is visiting your repl won't be able to see the contents of this file.
Now let's edit main.py
to include the following in the console:
from flask import Flask, request, redirect
import os
app = Flask(__name__)
@app.route('/')
def hello_world():
return redirect('/secret_route?secret=pass1234')
@app.route('/secret_route')
def secret_route():
password = request.args.get('secret')
if (password == os.environ['PASSWORD']):
return 'You found the secret!'
else:
return 'Wrong password!'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080)
We're creating a new page where we look for a query parameter secret
and we check to see if it matches our .env
secret. The gif below demonstrates the results.
Note that this isn't a very secure way of handling secret tokens, since the URL including the query parameter can be cached. This is just a simple demonstration.
Now that you've created your first repl, feel free to share it with our community! Here's how:
Feel free to join our Discord Community as well! Join with this invite link.
If you're interested in exploring more and seeing what you can do with Replit, take a look at the following repls:
You can find tutorials created by members of our community here. There are tutorials for creating single player and multiplayer games, web apps, Discord bots, and AI programs. Be sure to give the post an upvote if you enjoyed it!
If you want to check out other cool repls that people have shared, you can find them on Share.
If you have a question about programming or need help debugging something, be sure to post on Ask. Someone will help you if they can!
Enjoy being a Repler! We would love to hear more from you about how you use Replit, how you found out about Replit, and if there's anything we can do to improve. Feel free to contact us through any of the following avenues: