Welcome to Repl.it! This guide is meant to give you a quick overview of the many features of Repl.it. We're very excited to introduce you to a new workflow that can change the way you write code.
No programming knowledge is necessary. This quick start guide is in Python.
On your Repls Dashboard, you create a new repl by clicking on "Start Coding Now" or the red button in the bottom right corner. This will bring you to a page with a list of our supported languages.
Go ahead and select Python. This will bring you to your workspace.
The first thing to do when creating a repl is to give it a name and description. This will make it easier to come back to later, and will help with organizing your repls.
You can edit the name and description of the repl by clicking on the edit icon highlighted below, then editing the text fields to change the name and add a description. Clicking off the popover will automatically save any changes you've made.
There are three main parts to the Repl:
Let's start with the Console/Terminal. In that section, type in the following and hit enter:
Here you can evaluate code line by line and interact with its results. Now let's try entering the following:
x = "hey"
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. Type in the following python 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) / 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!
Let's use the
matplotlib package to make a simple plot. Clear the existing code, click on the packages icon on your sidebar, and enter
matplotlib to search for the package. Select the first one (indicated by the arrow).
Click on the
+ button to add it to your packages.
This will create a new file,
requirements.txt, which contains all the package information for your repl, including the version number. It will also start installing on the right.
We can view all of our files by selecting the filetree icon on our sidebar - the first icon. Click on the filetree icon, then 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 both the filetree and below the editor so you can see it! Neat, huh?
Let's create a new Python3 repl. As a shortcut, you can create a new repl by going directly to https://repl.it/languages/python3. 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
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 put some private information, such as an API key, or a database password, you can use
Create a new file by clicking on the File+ icon in your filetree. Name it
.env files contain key-value pairs like the following. Type in:
.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:
from flask import Flask, request import os app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello, Repler!' @app.route('/secure-page') 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 param
secret and we check to see if it matches our
.env secret. Watch the video below to see the results.
Of course, this is a very insecure way of handling secret tokens, since the URL including the query parameter can be cached. This is just a simple demonstration.
Finally, now that you've created your first repl, feel free to share it with our community!
Feel free to join our Discord Community as well! Join with this invite link.
If you're interested in exploring more in what you can do on Repl.it, take a look at the following repls:
You can find tutorials created by members of our community on Learn. 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 Repl.it, how you found out about Repl.it, and if there's anything we can do to improve. Feel free to contact us through any of the following avenues: