The site allows order or come to our restaurant and eat special food. Foods are unique you cant find this in another restaurant.
- ✅ User registration and authorization
- ✅ Unique login
- ✅ Menu with categories
- ✅ Saving orders in the database
- ✅ Food and Merch details
- ✅ Footer with information about the author on all pages
The project uses the environs library and reads settings from the .env file, which must be located in the root of the project.
Example file .env:
SECRET_KEY=your_secret_key
ALLOWED_HOSTS = [hosts]
DEBUG = True or False
| Variable | Purpose |
|---|---|
| SECRET_KEY | Flask Secret Key |
| ALLOWED_HOSTS | It ensures your Django app only responds to requests from trusted domains. "*" is all |
| DEBUG | Controls whether the app is in development or production mode |
It is recommended to use venv to isolate project dependencies.
python -m venv venv- Windows:
source venv\Scripts\activate- Mac/Linux:
source venv/bin/activate- Clone the repository:
git clone https://github.com/kerem212012/anime_restaurant.git
cd anime_restaurant-
Create and activate a virtual environment (see above)
-
Install dependencies:
pip install -r requirements.txt-
Create a
.envfile in the root of the project and specify the variables (SECRET_KEY,DEBUG,ALLOWED_HOSTS) -
Migrate project and create superuser:
python manage.py makemigration
python manage.py migrate
python manage.py createsuperuser- Start the server:
python manage.py runserver- Go to the browser:
| URL | name |
|---|---|
| / | Home page |
| /register | New user registration |
| /login | Login |
| /logout | Logout |
| /contact | About as |
| /shop | Sell food and merch |
| /product/id | Product details |
The site was created for money making(fake)
You need buy site from services I prefer TimeWeb Cloud
You need git bash,
open git bash and print ssh 'your ip' then he asks yes or no say yes.
Then give him password of site.
After enter write reboot.
Open .ssh file open file config in notebook.
And write:
Host 'name'
HostName 'your ip'
User root
Now you can enter your server like ssh 'name'.
In your site(in git bash) you need come to opt file. For this you need do:
cd ..
cd opt/After it, you need copy project. Example:
git clone https://github.com/kerem212012/anime_restaurant.gitInstall gunicorn to do it enter to your project in bash from opt add venv:
python -m venv venv
source venv/bin/activate
pip install -r requirements.txtNow installing gunicorn:
apt update
pip install gunicornNow to add daemon we need go to system file:
cd ..
cd ..
cd /etc/systemd/systemWe need add file we can do it with nano:
nano name.serviceIn this file add:
[Unit]
Description=Gunicorn instance for project_name
After=network.target
[Service]
WorkingDirectory=/opt/project_name
Environment="PATH=/opt/project_name/venv/bin"
ExecStart=/opt/project_name/venv/bin/gunicorn --workers 3 --bind unix:/opt/project_name/app_name.sock app_name.wsgi:application
[Install]
WantedBy=multi-user.target
Then lets start it:
systemctl start name.service
systemctl status name.serviceNow let's add nginx:
apt install nginx
cd /etc/nginx/sites-available
nano deafultDelete all and write this if you want with ip:
server {
listen 80;
server_name your ip;
location /static/ {
root /opt/project_name/staticfiles/;
}
location /media/ {
alias /opt/project_name/media/;
}
location / {
include proxy_params;
proxy_pass http://unix:/opt/project_name/app_name.sock;
}
}
If with domain buy domain like example.ru:
server {
listen 80;
server_name name.ru www.name.ru;
location /static/ {
alias /opt/project_name/staticfiles/;
}
location /media/ {
alias /opt/project_name/media/;
}
location / {
proxy_pass http://unix:/opt/project_name/app_name.sock;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
apt install certbot python3-certbot-nginx
certbot --nginx -d name.ru -d www.name.ruAdd CSRF_TRUSTED_ORIGINS = env.list("CSRF_TRUSTED_ORIGINS") in settings.py and add CSRF_TRUSTED_ORIGINS = http://name.ru, https://name.ruto .env.